- Home /
Question by
elsharkawey · Feb 27 at 07:56 AM ·
movementcharactercontroller
character controller component not moving my character forward it's only rotating it around it self
i tried many scripts to move it but i got the same problem
my ground are static and have an box collider
my last script
using UnityEngine; using System.Collections;
[RequireComponent(typeof(CharacterController))] public class controllbrcky : MonoBehaviour {
public float speed = 3.0F;
public float rotateSpeed = 3.0F;
void Update()
{
CharacterController controller = GetComponent<CharacterController>();
// Rotate around y - axis
transform.Rotate(0, Input.GetAxis("Horizontal") * rotateSpeed, 0);
// Move forward / backward
Vector3 forward = transform.TransformDirection(Vector3.forward);
float curSpeed = speed * Input.GetAxis("Vertical");
controller.SimpleMove(forward * curSpeed);
} }
Comment
Answer by V_0_1_D_ · Feb 27 at 11:27 AM
Nothing is wrong with the script and it works well. Check Vertical in your input manager and make sure it's assigned to (w,s). otherwise you may have a script that conflicts with this one.
Your answer
Follow this Question
Related Questions
Character controller or rigidbody? for skateboard 1 Answer
Jet-Pack Script 1 Answer
Controlling speed of diagonal navmesh movement? 0 Answers
Turning to face movement direction 0 Answers
Animation not working correctly, character is going up 0 Answers