UnityNinja Community
Would you like to react to this message? Create an account in a few clicks or log in to continue.

UnityNinja CommunityLog in

UnityNinja - Video Game Development Community, including Resources, Forums, Marketplace & More.


descriptionMovement script broken EmptyMovement script broken

more_horiz
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

descriptionMovement script broken EmptyRe: Movement script broken

more_horiz
Ignore this post...a friend just fixed it for me Very Happy

gotta love having friends
privacy_tip Permissions in this forum:
You cannot reply to topics in this forum
power_settings_newLogin to reply