public var MoveSpeed :float = 50;
public var jumpSpeed : float = 55;
public var MoveDirection = Vector3.zero;
public var Gravity :float = 45;
public var grounded : boolean = false;
function Start (){
}
function Update () {
if( grounded ){
MoveDirection = new Vector3(Input.GetAxis("Horizontal"), 0 , Input.GetAxis("Vertical"));
MoveDirection = transform.TransformDirection(MoveDirection);
MoveDirection *= MoveSpeed ;
}
if( grounded ) {
if(Input.GetKey(KeyCode.Space)){
MoveDirection.y = jumpSpeed;
}
}
MoveDirection.y -= Gravity * Time.deltaTime;
var Controller = GetComponent(CharacterController);
var Flags = Controller.Move( MoveDirection * Time.deltaTime);
grounded = (Flags & CollisionFlags.CollidedBelow) !=0;
}
if possible you can also contact me via ********* and teamview me for a better look. I am using Unity Pro but i went to go ask on their forum and they were of no help.
*Edited: email address removed according to this site policies
And by the way you are in the Java forum, nothing to do with your code
Not sure in which language it is written to move it to the good forum
This post has been edited by pbl: 23 November 2011 - 09:42 PM

New Topic/Question
Reply




MultiQuote








|