- Home /
Rotate an angle
I want to rotate an angle in the local space (kinda).. ill explain.
So i am firing an object out of an cannon (original i know) - but the transform.forward of the cylinder faces down at the ground.
If i do:
c.localEulerAngles.x -= 90;
rigidbody.AddForce(c.forward*powerValue*200);
c.localEulerAngles.x += 90;
I get my desired result. I would like to know the (non hack) way to do this properly.
cheers Tony
Answer by Jean-Fabre · Apr 13, 2011 at 11:36 AM
Hi,
Simply use either c.up or c.right instead of c.forward. If fired in the wrong direction, use then -c.up or -c.right.
That then should work properly without any hack.
Bye,
Jean
Good thinking. Also, Just say i want to change it by a smaller value - eg. 25degrees. I am interested to know if there are helper functions. I was thinking Vector3.rotate, or do i multiply the vector by another? just wondering, as i'm sure i might need to do this in the future
ins$$anonymous$$d of using c as the base to define the force direction, use another transform, like the transform of the canon. Else position and rotate your bullet properly before firing. $$anonymous$$aybe I misunderstand your question tho.