Friday, October 22, 2010

video #6

Here's the script that he used in the last video
var speed = 3.0;
var rotateSpeed = 3.0;
var bullitPrefab:Transform;

function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);

// Rotate around y - axis
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);

// Move forward / backward
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis ("Vertical");
controller.SimpleMove(forward * curSpeed);

if(Input.GetButtonDown("Jump"))
{
var bullit = Instantiate (bullitPrefab,
GameObject.Find("spawnPoint").transform.position,
Quaternion.identity);
bullit.rigidbody.AddForce(transform.forward * 6000);
}

}

@script RequireComponent(CharacterController)

No comments:

Post a Comment