Im trying to make my character do sort of a double jump if it is facing a wall and if the player has pressed the spacebar twice. Ive looked around for an answer for this but they are all to confusing for my little brain to make sense of, can anyone help me out?
First make an empty object and place it in the Player as a child then give a Box collider to the emptyObject
Then Try using this script in the EmptyObject for Double jumping when the player face the wall.
var Player : Transform;
var FacingWallorNot : int;
function Update () {
if(FacingWallorNot == 1){
var PlayerMovement = Player.GetComponent(PlayerMovementAndJumpingScript);
//Change the variable in the PlayerMovementAndJumpingScript here using "PlayerMovement.[VariableName] = [number value you want it to change];
}
}
function OnTriggerEnter(other:Collider){
if(other.gameObject.tag == "Wall") {
FacingWallorNot = 1;
}
}
Put a “Wall” tag on the wall object.
use a ray cast