Hello
This is the code we are using to move the player. The idea being the controls are relative to the cameras position as the camera changes (similar to FEZ fashion).
Problem is now we have this working, we need the players character to face the direction it is moving in. We are currently trying with the movement on the parent object and attempting to rotate the child character object. If that makes sense.
This is the movement script.
void Update ()
{
//Jump
if (Input.GetKeyDown (KeyCode.Space) && (doubleJump < 2)) {
rb.AddForce (new Vector3 (0, 1, 0) * jumpforce);
doubleJump++;
}
//movement
if (Input.GetKey (KeyCode.UpArrow))
{
movement = transform.position += Camera.main.transform.forward * speed;
hammy.transform.LookAt(movement);
}
if (Input.GetKey (KeyCode.DownArrow))
{
movement = transform.position -= Camera.main.transform.forward * speed;
hammy.transform.LookAt(movement);
}
if (Input.GetKey (KeyCode.LeftArrow))
{
movement = transform.position -= Camera.main.transform.right * speed;
hammy.transform.LookAt(movement);
}
if (Input.GetKey (KeyCode.RightArrow))
{
movement = transform.position += Camera.main.transform.right * speed;
hammy.transform.LookAt(movement);
}
This is the camera follow script
void LateUpdate()
{
//Follows the Players Position
parent.transform.position = target.transform.position;
//Lerps and chnages the cameras positon relevent to the Player
transform.position = Vector3.Lerp (transform.position, currentCamera.transform.position, Time.deltaTime * 1.5f);
transform.rotation = Quaternion.Lerp (transform.rotation, currentCamera.transform.rotation, Time.deltaTime * 1.5f);
}
We have spent hours trying to figure this out.
Any help would be greatly appreciated.
Thanks
