Hi, I'm trying to shoot a projectile, I can make it work with the following code. But the only problem is I want it to spin as it flys through the air and my last line of code doesn't seem to be working. How can I modify the following to make it spin on its z axis while flying? Code (csharp): var projectile : Rigidbody; function Update () { if (Input.GetButtonDown("Fire1")) { var clone : Rigidbody; clone = Instantiate(projectile, transform.position, transform.rotation); clone.velocity = transform.TransformDirection (Vector3.forward * 30); // This is where I need help: clone.angularVelocity = (Vector3.forward * Time.deltaTime); } } Thanks a lot, Stuart
Vector3.forward is the world's Z axis. transform.forward is the local Z axis. But you should AddTorque instead.
Use functions that make physical sense as much as you can when scripting physics. Other forces can stop your angularVelocity from ever being met, but the torque would exist at that moment no matter what.