I have a camera that orbits my game object looking at the object from either north, south, east, west. I can’t seem seem to keep the controlls consistant once the camera rotates the controlls are inverted, help
my scripts
my input script
using UnityEngine;
using System.Collections;
public class InputManager : MonoBehaviour
{
CameraControll cam;
void Start()
{
cam = GetComponent<CameraControll>();
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.LeftArrow))
{
cam.MoveHorizontal(true);
}
else if(Input.GetKeyDown(KeyCode.RightArrow))
{
cam.MoveHorizontal(false);
}
else if (Input.GetKeyDown(KeyCode.UpArrow))
{
cam.MoveVertical(true);
}
else if (Input.GetKeyDown(KeyCode.UpArrow))
{
cam.MoveVertical(false);
}
}
}
my camera movement script
using UnityEngine;
using System.Collections;
public class CameraControll : MonoBehaviour
{
public Transform target;
public float horizMove = 45f;
public float VertMode = 15f;
public void MoveHorizontal(bool left)
{
float dir = 1;
if (!left)
dir *= -1;
transform.RotateAround(target.position, Vector3.up, horizMove * dir);
}
public void MoveVertical(bool right)
{
float dir = 1;
if (!right)
dir *= -1;
transform.RotateAround(target.position, transform.TransformDirection(Vector3.right), VertMode * dir);
}
}
my player movement script
using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour
{
public float speed;
private Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rb.AddForce(movement * speed);
}
}
How do I keep my player movement consistant relative to the camera’s position