Hi everyone,
I am pretty noob in Unity but i am having some trouble that i don´t understand. I saw some tutorials where they assign a initial velocity to a rigidbody, and i am doing the exactly same thing and it´s not working. They do it in the Start() method but for me only works on the Update method. This is really a problem for me because i need it on the Start method in order to not assinging the same velocity in every frame.
Like this doesnt work:
public class testVelocity : MonoBehaviour {
public Vector3 initialVelocity;
public Vector3 initialAngularVelocity;
private Rigidbody rigidBodyBall;
// Use this for initialization
void Start () {
rigidBodyBall = GetComponent<Rigidbody>();
rigidBodyBall.velocity = initialVelocity;
rigidBodyBall.angularVelocity = initialAngularVelocity;
}
// Update is called once per frame
void Update () {
}
}
It only works like here:
public class testVelocity : MonoBehaviour {
public Vector3 initialVelocity;
public Vector3 initialAngularVelocity;
private Rigidbody rigidBodyBall;
// Use this for initialization
void Start () {
rigidBodyBall = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update () {
rigidBodyBall.velocity = initialVelocity;
rigidBodyBall.angularVelocity = initialAngularVelocity;
}
}