Unity Ninja Unity 3D Forum
To have exclusive access to all downloads, recourses and links within this forum, a free registered account is required. Just a heads up Wink

You are not connected. Please login or register

Unity Ninja Unity 3D Forum » HELP » Help (General) » Movement script broken

Movement script broken

View previous topic View next topic Go down  Message [Page 1 of 1]

1 Movement script broken on Thu Aug 13, 2015 12:53 am


Member [Lv. 1]
Member [Lv. 1]
hiya im just asking if this script is right because it all works till i ask it to allow me to tilt the camera on the X axis

using UnityEngine;
using System.Collections;

public class FirstPersonController : MonoBehaviour {

public float movementSpeed = 5.0f;
public float mouseSensitivity = 5.0f;
public float updownRange = 40.0f;

// Use this for initialization
void Start () {


// Update is called once per frame
void Update () {

// Rotation

float rotLeftRight = Input.GetAxis ("Mouse X") * mouseSensitivity;
transform.Rotate (0, rotLeftRight, 0);

float rotUpDown = Input.GetAxis ("Mouse Y") * mouseSensitivity;
Camera.main.transform.Rotate( rotUpDown, 0, 0 );

// Movement
float forwardSpeed = Input.GetAxis ("Vertical") * movementSpeed;
float sideSpeed = Input.GetAxis ("Horizontal") * movementSpeed;

Vector3 speed = new Vector3 (-sideSpeed, 0, -forwardSpeed );

speed = transform.rotation * speed;

CharacterController cc = GetComponent<CharacterController> ();

cc.SimpleMove ( speed );


what happens is i get stuck and all i can do is look around in a 360 rotation

View user profile

2 Re: Movement script broken on Thu Aug 13, 2015 1:08 am


Member [Lv. 1]
Member [Lv. 1]
Ignore this post...a friend just fixed it for me Very Happy

gotta love having friends

View user profile

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum