Could anyone help me please i have been following a tutorial on brackets on how to make an fps game and i go to run my game (There are absolutely no errors in the code ) but when i hit the keys W A S and D or the arrows it doesn’t do anything and i think there are different keys that you have to press in order to move your character but i haven’t figured it out yet, could anybody help me please?
These are my two scripts and my only 2 that i have so far:
PlayerController:
[ using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
public class PlayerMotor : MonoBehaviour {
private Vector3 velocity = Vector3.zero;
private Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
}
public void Move(Vector3 velocity)
{
velocity = velocity;
}
void FixedUpdate()
{
PerformMovement();
}
void PerformMovement()
{
if (velocity != Vector3.zero)
{
rb.MovePosition(rb.position + velocity * Time.fixedDeltaTime);
}
}
}
]
[/code]
AND my other script which is PlayerMotor:
[ using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
public class PlayerMotor : MonoBehaviour {
private Vector3 velocity = Vector3.zero;
private Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
}
public void Move(Vector3 velocity)
{
velocity = velocity;
}
void FixedUpdate()
{
PerformMovement();
}
void PerformMovement()
{
if (velocity != Vector3.zero)
{
rb.MovePosition(rb.position + velocity * Time.fixedDeltaTime);
}
}
}
]
[/code]
p.s There are no errors in the script that the game has dented just 2 yellow warnings:
-
- Assets/PlayerController.cs(19,9): warning CS0219: The variable `zMov’ is assigned but its value is never used
-
- Assets/PlayerMotor.cs(17,3): warning CS1717: Assignment made to same variable; did you mean to assign something else?