- Home /
How to set an exact Local angle.
I'm by no means a rookie programmer but this problem has plagued me for months and i've worked around it but never really solved it, I've got a dropship and the thrusters on the side rotate, I want to set there angle to the current speed of the dropship and for them to just rotate around there mid point, ideally i would love it to just be transform.rotation.x = dropship.CurrentSpeed. So far using euler angles i havent managed to get it to work. I should add also that the thrusters are children of the main air frame of the ship which rotates serperately as well. Cheers!
PS to clarify i want the angle set to the speed of the ship, so if it is moving at a constant speed they will not be rotating.
Could use more detail to fully grasp your question. In what way do the engines rotate? Is it a sort of harrier jet type motion? The jets point towards the ground when it is stationary but slowly rotate to adjust thrust to the back of the craft as it comes to speed?
Also, why would the speed of the ship equal the rotation of the engine?
Seems like you would want to set the rotation to the acceleration of the craft, not the speed.
I try to avoid Euler angles whenever possible, I dont fully understand them yet.
So you want the rocket flames pointed down when hovering, horizontal when flying forward and all the in between?
How about
-define 2 rotations, one fwd one up
if (velocity.magnitude>1){
slerp to fwd rotation using velocity.magnitude/7 as 3rd parameter
}
else
slerp to vertical
I'm fuzzy here about how they rotate, but say they rotate on their local 'z' axis. You can do:
transform.localRotation = Quaternion.AngleAxis(speed * factor, Vector3.forward);