I am currently stuck on making movement for my 3D game. What I want to do is I want you to be able to control the character with the WASD keys, and the mouse can turn the direction. (FPS style movement) In my old script which I have deleted due to it being inefficient, the movement worked with the mouse, except the only problem is that it was really wonky. I have tried other scripts, which don't work with the mouse and just bounce the player around the map for some reason. Here is the script that I have right now:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading;
public class movement : MonoBehaviour
{
public GameObject step;
public float movementspeed = 5.00f;
private float shiftspeed = 5.00000005f;
public Rigidbody rigidbody;
private Vector3 movementinput;
private void Update()
{
movementinput = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")).normalized;
}
private void Start()
{
rigidbody = gameObject.GetComponent<Rigidbody>();
}
private void FixedUpdate()
{
movementfunction(movementinput);
}
void movementfunction(Vector3 direction)
{
rigidbody.velocity = direction * 5;
}
}