var speed = 3.0;
var rotateSpeed = 3.0;
function Update () {
var controller : characterController = Getcomponent(CharacterController);
transform.Rotate(0, input,GetAxis (“Horizontal”) * rotateSpeed, 0);
var forward = transform.TransformDirection(vector3,forward);
var curSpeed = speed * Input,GetAxis (“Vertical”);
controller,Simplemove(forward * curSpeed);
i need to know if im spelling everything ok?thanks
That won’t work.
You miss a } and ou have a unconnected controller followed by a , that does nothing.
all this you would get a warning about in unity with rows, so i won’t clean up our code for you.
This should get you started.
public var speed : float = 3.0;
puplic var rotateSpeed : float = 3.0;
function Update () {
//move forward and backward
var fwd : float = Input.GetAxis("Vertical");
transform.Translate(Vector3(0,0, fwd * speed));
//turn left and right
var yaw : float = GetAxis("Horizontal");
tranform.Rotate(Vector3(0,yaw * rotateSpeed,0));
}
/// This script moves the character controller forward
/// and sideways based on the arrow keys.
/// It also jumps when pressing space.
/// Make sure to attach a character controller to the same game object.
/// It is recommended that you make only one call to Move or SimpleMove per frame.
var speed : float = 6.0;
var jumpSpeed : float = 8.0;
var gravity : float = 20.0;
private var moveDirection : Vector3 = Vector3.zero;
function Update() {
var controller : CharacterController = GetComponent(CharacterController);
if (controller.isGrounded) {
// We are grounded, so recalculate
// move direction directly from axes
moveDirection = Vector3(Input.GetAxis(“Horizontal”), 0,
Input.GetAxis(“Vertical”));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
if (Input.GetButton (“Jump”)) {
moveDirection.y = jumpSpeed;
}
}
// Apply gravity
moveDirection.y -= gravity * Time.deltaTime;
// Move the controller
controller.Move(moveDirection * Time.deltaTime);
}
i just found this code in unity reference so it works.
i was also wondering why i dont have smoothfollow in unity?
or first person shooter prefab?