Hi, I'm having issuse with the code. the movement is effected by the camera rotation, how can I fix that ?
thanks
here are the code and the video
public Transform PlayerHolder;
public Transform CamHolder;
public Rigidbody RGB;
[Header("Movement")] public float BaseSpeed = 4f;
[HideInInspector] public Vector3 MoveInput, CamInput, MoveUse, CamInputUse, CamPosition, RefCamPos;
void LateUpdate(){
CamFunction();
CamHolder.position = PlayerHolder.position;
}
void FixedUpdate(){
MoveFunction();
}
void MoveFunction(){
MoveInput = new Vector3(Input.GetAxisRaw("Horizontal"), 0f, Input.GetAxisRaw("Vertical"));
MoveUse = CamHolder.TransformDirection(MoveInput.normalized * BaseSpeed * Time.fixedDeltaTime);
MoveUse.y = 0f;
RGB.MovePosition(PlayerHolder.position + MoveUse);
}
[Header("Camera")] public float CamSpeed = 2.5f;
[Range(0, 80)] public int TopViewLimit = 80;
[Range(0, 40)] public int BotViewLimit = 30;
void CamFunction(){
CamInput = new Vector3(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"), 0f);
CamInputUse += new Vector3(- CamInput.y, CamInput.x) * CamSpeed;
CamInputUse.x = Mathf.Clamp(CamInputUse.x, -BotViewLimit, TopViewLimit);
CamHolder.rotation = Quaternion.Euler(CamInputUse);
}