Hi!
I’ve got a little problem with rotating an object with transform.rotate, while I use rigidbody.addforce to move it forward.
Right now my object rotates and when I let go of the keys used for rotating my game will have a slight lag of about a frame or 2.
I think it has something to do with using transform and rigidbody together. Is there some sort of alternative version of transform.rotate for rigidbodies?
Here’s the function I use to make my object move…
function Movement()
{
if(!canHover && Input.GetAxis("Vertical") <= 0 && Controlled == true)//move the ship IF the ship can't hover, isn't pressing the forward key and is controllable
{
myRigidbody.AddForce(transform.forward*50000);
}
if(Input.GetAxis("Vertical") > 0 && Controlled == true)//If the player is pressing forward and the ship can be controlled, move forward
{
myRigidbody.AddForce(transform.forward*translation*100000);
}
transform.Rotate((-mouseY/1000*pitchSpeed),(mouseX/1000*yawSpeed),(-hor-mouseX/1000*rollSpeed));//Rotate the ship according to the mouse input
}
Anyway, any suggestions are highly appreciated!
Thanks in advance,
Nick