I have my first person controller approach a wall. When i sprint and collide i want the character to climb animation. It works and plays the animation but it plays it in the wrong spot, not relative where the player is. Please help. This is the script:
var touchingWall : boolean = false;
var isSprinting : boolean = false;
var isClimbing : boolean = false;
var playerObject : GameObject;
function Update ()
{
varControl ();
climbing ();
}
function varControl ()
{
if (Input.GetAxis("Vertical") && Input.GetButton("Sprint"))
{
isSprinting = true;
}else{
isSprinting = false;
}
}
function OnControllerColliderHit(hit : ControllerColliderHit)
{
if (hit.gameObject.tag == "climbable")
{
touchingWall = true;
}else{
touchingWall = false;
}
if (hit.gameObject.tag == "climbend")
{
isClimbing = false;
}
if (touchingWall && isSprinting)
isClimbing = true;
}
function climbing ()
{
if (isClimbing)
playerObject.animation.CrossFade("ClimbAnimation", 0.4);
}
↧