4DIS - Character Controllers

From Unify Community Wiki
Jump to: navigation, search

Character Controllers


Roll a ball :

<javascript>

@script RequireComponent ( Rigidbody )

public var speed : float = 5.0; public var force : float = 7.5;

private var motion : Vector3 = new Vector3 ( 0, 0, 0 );

function Update ( ) {

   if ( Input.GetKey ( input.buttonUp ) )
       motion.z = speed;
   else if ( Input.GetKey ( input.buttonDown ) )
       motion.z = - speed;
   else
       motion.z = 0;
   
   if ( Input.GetKey ( input.buttonUp ) )
       motion.z = speed;
   else if ( Input.GetKey ( input.buttonDown ) )
       motion.z = - speed;
   else
       motion.z = 0;
   
   rigidbody.velocity = Vector3.Lerp ( rigidbody.velocity, motion, Time.deltaTime * force );

}

class

</javascript>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox