07-12-2012, 12:11 PM
Non so prova, ma eccoti anche con character control
Codice:
var jumpSpeed = 35;
var controller;
var gravity = 20.00;
var isJumping: boolean = false;
var Jump : boolean = false;
private var moveDirection : Vector3 = Vector3.zero;
function Update()
{
var controller : CharacterController = GetComponent(CharacterController);
if (controller.isGrounded)
{
isJumping = false;
}
if (Jump)
{
isJumping = true;
}
if (isJumping)
{
Jump = false;
controller.Move(moveDirection * Time.deltaTime);
}
moveDirection.y -= gravity * Time.deltaTime;
}
function OnControllerColliderHit(hit:ControllerColliderHit) {
if (hit.gameObject.tag == "Bounce")
{
print("afaf");
Jump = true;
moveDirection.y = jumpSpeed;
}
}