- Home /
Question by
Umberghast · Aug 30, 2021 at 06:29 PM ·
not workingtutorial3rd person controller
I watched a tutorial but my player isnt moving
I was working on a Brackeys tutorial, the "THIRD PERSON MOVEMENT in Unity", and at this point in the video, he tests it and it works. my code is exactly the same as far as i see and the speed variable isnt 0, but my character doesnt move. heres my script:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class movement : MonoBehaviour { public CharacterController controller;
public float speed = 6f;
// Update is called once per frame
void Update()
{
float horizontal = Input.GetAxisRaw("Horizontal");
float vertical = Input.GetAxisRaw("Vertical");
Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized;
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);
}
}
} .
Is there anything i can do?
Comment
Your answer
Follow this Question
Related Questions
Why is the boundary not working? 1 Answer
Laser not causing damage 1 Answer
rollaball ball wont move 2 Answers
Plug in for tutorial videos 1 Answer