Hey guys, so I’m just prototyping a generic top down shooter, and I’m running into some issues. For simplicity reasons, the camera is static at a fixed position (See gif below)
The movement worked fine until I tried adding look rotation. Currently, the players forward is being set to the mouse position? The rotation and movement should be independent of eachother. Here I demonstrate whats going on:

As you can see, the rotation works fine. However pressing forward (W) causes the player to move towards the mouse. W should always move the player forward on the Z axis, not towards the mouse pos.
Heres the script attached to the player:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float speed = 1f;
Vector3 lookPos;
Camera cam;
void Start()
{
cam = FindObjectOfType<Camera> ();
}
void Update()
{
Ray ray = cam.ScreenPointToRay (Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast (ray, out hit, 100))
{
lookPos = hit.point;
}
Vector3 lookDir = lookPos - transform.position;
lookDir.y = 0;
transform.LookAt (transform.position + lookDir,Vector3.up);
float moveVert = Input.GetAxisRaw ("Vertical") * Time.deltaTime * speed;
float moveHoriz = Input.GetAxisRaw ("Horizontal") * Time.deltaTime * speed;
Vector3 movement = new Vector3 (moveHoriz, 0, moveVert);
//movement.Normalize ();
transform.Translate(movement);
}
}
So can someone help me understand whats going on here? I tried following a yt video, but obviously its not really working as intended. I would ask questions on some of the parts I dont understand, but those may be the parts that are causing the issues so ill save those questions for when this is solved.