I have a fairly simple PlayerContoller at the moment which just happens to be for a space type game.
It currently moves my ship with pitch, yaw and roll. When a yaw I have it banking(angling) my ship in the proper direction, but I would like it to RInterp in that direction instead of teleporting. Can anyone please let me know where and what I need to do with it, or even just a helpful (here it comes) kick in the right direction to the documentation?
Sorry Ninjachimp I pasted a code block but it is not broken and self contained.
public class PlayerController1 : MonoBehaviour {
public float xShip;
public float yShip;
public float zShip;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void FixedUpdate () {
xShip = Input.GetAxis(âHorizontalâ) * Time.deltaTime * 25.0f;
yShip = Input.GetAxis(âVerticalâ) * Time.deltaTime * 25.0f;
zShip = Input.GetAxis(âRollâ) * Time.deltaTime * 25.0f;
I use it a lot for some of my games. Apart from that, apologies, I got really confused with âpitchâ and âyawâ? Hopefully Vector3.Lerp is what you need?
I am heading out for the night so I will look into this in the morning. Pitch is the Up/Down (vertical axis) movement of an object like an airplane, Yaw is the Right/Left (horizontal axis) movement.
Try using quaternions for rotations like that, Vector3 isnât ideal to handle complex rotations. What may be the problem here is that you are adressing the new quat to the localrotation, try adding it to the actual rotation instead ( â+=â instead of â=â) let me know if you manage to fix that, otherwise I can take a further look on that. This video helped me a lot, you may benefit from watching it too:
What I ended up doing is creating an empty object and added my meshes to it (they are in multiple parts) then added a banking script above to the banking object.
Here is a quick video of the final product. Its not perfect but I can dig into that another day.