I could really use some help. I have a boat and I am trying to move it forward by inrements of 2. My problem is that the boat is rotated on the y axis by 35 degrees so when i move it forward it moves slightly diagonal. Can anyone point me in the right direction on how to move it forward and include the angle of rotation on the y axis so that the boat moves in a straight line? Any help would be appreciated.
I’m confused about your boat and its rotation. Are you saying it’s been modeled such that its own axes aren’t aligned with the boat itself? If that’s the case (the z-axis isn’t aligned with the beam of the boat) then you need to either (a) remodel it to align those, (b) child the boat model to an empty game object that is aligned nicely, or (c) figure out exactly what the offset is so you can use that value instead.
Otherwise maybe this is a question of using local versus world coordinates if the model’s axes are in fact properly aligned with its geometry. What’s the code you’re using if that’s the case?
Thanks for the reply. The axis of the model is correct. my problem is that when I place the boat on the water and align it with the dock I have to rotate the object on the y axis by 35 degrees. so when I try to move it forward the boat moves diagonal. I have tried everything to determine the rotation of the boat and have not been successful.
Vector3.forward will give you a generic world-relative forward direction ( 0,0,1 ). Instead, transform.forward will give you the boat’s forward direction (the boat’s local z-axis) which is what you really want.
solved using transform.Translate(transform.forward * Time.deltaTime); so might be good to make a more elaborated manual or wiki for such important noob issues