Hey guys!
Let me Get Straight to the point.
The problem with my code is, that I have two scripts: One for the movement and other is the animation controller. Also, im using raycast for my jump.
So, basically the first program moves and controls jumps.
The other one will disable the jump in the first one. The problem is, that the player
will just jump with repeated UpArrow taps,and will also climb walls with the same.
Is there any way to AVOID doing this?
Code:
//Player Code
var units = 2.0;
var CanJump = true;
var PlayerCollider : GameObject;
function Update()
{
//player movements in game area
//move the player ahead
MyAnimatedModel.animation.Play(RunAnimation.name);
transform.position += transform.forward * units * Time.deltaTime;
if (CanJump != false);
{//jumping system
if (Input.GetKeyDown (KeyCode.UpArrow)){
rigidbody.AddForce(PlayerCollider.transform.up * 250, ForceMode.Acceleration);
MyAnimatedModel.animation.Play(PlayerJumpAnimation.name);
}
}
}
Here is script #2
// Animation/Movement moderator and controller
var ThePlayer : GameObject;
var Air : String;
function OnTriggerEnter( other : Collider ) {
Debug.Log("Collision Signal Detected");
if (other.tag == Air)
{
ThePlayer.GetComponent(MoveScript).CanJump = false;
}
}