Hi, in my application I have a prefab object, which I instantiate and add a relative force.
Just like this:
var projectile: GameObject;
projectile = Instantiate(projectilePrefab, transform.position, transform.rotation);
projectile.rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
projectile.rigidbody.AddRelativeForce(new Vector3(0, 0, 2000));
The problem is that I want to let the user set the mass and acceleration, so I can calculate the Force Formula (F = m.a) and add it to the projectile.
With the mass I do this, but I'm not sure if it will work...
//seting projectile data
projectilePrefab.rigidbody.mass = massUser;
But how about the acceleration, how can I set it to be calculated?
I'm a newbie in Unity and I've checked online and I still can't seem to get it. Any help is appreciated. Thank you for your time.
↧