Im trying to have 2 characters operated by different keys. One uses WSAD and one uses up down left and right to move. Im using a script that I found and followed a tutorial on that allows my characters to shoot in the direction they are looking but they both use WSAD and arrow keys to move. I need some help making one script have arrow key movement and one having WSAD while retaining the shooting mechanic i mentioned. Heres the script for the movement. Im using a controller so the characters dont spaz out when they get close to a wall. Seems like the only fix unless there is another.
{
public CharacterController controller;
public float speed = 6f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
//float x = Input.GetAxis("Horizontal");
//float z = Input.GetAxis("Vertical");
float horizontal = Input.GetAxisRaw("Horizontal");
float vertical = Input.GetAxisRaw("Vertical");
Vector3 direction = new Vector3(horizontal, 0f, vertical). normalized;
//Vector3 move = transform.right * x + transform.forward * z;
//controller.Move(move * speed * Time.deltaTime);
if (direction.magnitude >= 0.1f)
{
float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0f, targetAngle, 0f);
controller.Move(direction * speed * Time.deltaTime);
}
}
}