- Home /
Question by
Allsaveone · Sep 29, 2013 at 01:48 AM ·
c#inputcharactercontrollerrotate
How can i make my simple character controller rotate?
im trying to build a controller from the ground up, and im having difficulty getting my character to rotate under input, heres where i am so far
using UnityEngine; using System.Collections;
public class Player : MonoBehaviour {
public float playerSpeed = 4.0f;
public float rotationSpeed = 1.0f;
private Vector3 moveDirection = Vector3.zero;
//public var playerStartPoint = (0.0.0); Can i make Payerspawn public?
// Use this for initialization
void Start () {
//Player Spawn point
transform.position = new Vector3 (0,1,0);
}
void Update () {
transform.Translate(Vector3.forward * Input.GetAxis("Vertical") * playerSpeed * Time.deltaTime);
transform.Translate (Vector3.right * Input.GetAxis ("Horizontal") * playerSpeed * Time.deltaTime);
}
}
Comment
$$anonymous$$y advice is to look at the First Person Controller script that Unity provides for free, and look at how they go about it, and implement it into your code. Should be pretty straightforward.