- Home /
Movment Script not working
I've been working on a game recently and I just started on the player moment and I ran into an issue with the player not moving when I hit my input button, ive been following this tutorial series https://www.youtube.com/watch?v=Tm2L-_0eIeY&t by gamesplusjames
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float moveSpeed;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetAxisRaw("Horizontal") > 0.5f || Input.GetAxisRaw("Horizontal") < -0.5f )
{
transform.Translate (new Vector3 (Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime, 0f, 0f));
}
}
}
Answer by TheMostGeneralUnifier · Apr 18 at 03:29 PM
Have you set moveSpeed to some value in the UI in the Inspector window? The default value is 0, which would cause the player not to move at all.
Your answer
Follow this Question
Related Questions
Trying to fix my movement after the camera broke it. 0 Answers
How to make a 3rd person character controller 0 Answers
New to Unity & Scripting, How Do I Create a Movement System Thats About Building Up Speed? 0 Answers
Help with Mobile Game controls 2 Answers
Player sprints, but doesn't return to normal speed 3 Answers