My ball just drops on the floor. :)

I don’t believe my mistake is on the code as even if deleting my whole thing and pasting the code from the instructor, the ball still doesn’t rolls.

In my Ball Inspector I have Sphere Collider checked on, the mass set to 7,3 and LaunchSpeed set to 200.
I tried to reproduce all the steps on the video the same way as the instructor… and I can’t find my error.

My Unity version is 2017.3, and the code is pasted below.
Thank you for any help! :stuck_out_tongue_winking_eye:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Ball : MonoBehaviour {

public float launchSpeed;

private Rigidbody rigidBody;
private AudioSource audioSource;    

// Use this for initialization
void Start () {
    rigidBody = GetComponent<Rigidbody>();
    audioSource = GetComponent<AudioSource>();
    
    Launch();
}

public void Launch() {
    rigidBody.velocity = new Vector3(0, 0, launchSpeed);
    audioSource.Play();
}

// Update is called once per frame
void Update () {
	
}

}

Mhh your Code is fine.
All Capital Letters set right, u use the right syntax. This should work.
I tried your code and it work very well.

make sure ur GameoBject look something like this.
Rigidbody attached, use Gravity
Look that u not use Kinematic Settings.
AudioSource attached to not end in an Error
Make sure the Script is attached to the GameObject with Rigidbody and is not a Children or Parent of the Rigidbody.

Look if you set a Rigidbody and not a Rigidbody2D
Look that the static is turned off

I hope something of this helps you

Alex,

Thank you so much for your time, for trying my code! I really appreciate your effort!
I checked all you said and everything was fine.
After HOURS breaking my head I found out my mistake! When I first positioned the pins on their right spots, for some reason I moved everything visible, but the colliders of every pin stayed where they were before, in the beginning of the track, a little bit ahead of the ball!
And as the colliders are “invisible” (and for me being a newbie!) I could never understand why the hack my ball was flying high after throwing it! hahahaha
It’'s because it was colliding to all these invisible obstacles… :slight_smile:

Now I can finally follow along with the new sections!..
Thank you again!
Daniel

1 Like

Great that you found ur Problem and solved it by ur own. Thats a good move and for the future you maybe know about this stranges happen then you know from your experience how to handle this an you go through all the stuff and find the right Spot more easy

So Good luck and Have fun
Keep Going
regards Alex

1 Like

Privacy & Terms