Completely new here and will appreciate any and all advice given. My problem is I have a character that jumps but I would like it for her to only jump when she is standing on a platform. The problem is the code as I have it set up will always say she’s on a platform, even when she’s not. Here is my code:
var worldMouseDownPosition : Vector2;
var worldMouseUpPosition : Vector2;
var velocity : float;
var jumpForceMultiplier = 500;
var isFalling = true;
var readyToJump = false;
function Update () {
if (Input.GetButtonUp("Fire1") && isFalling==false && readyToJump==true){
worldMouseUpPosition = Camera.main.ScreenToWorldPoint (Input.mousePosition);
gameObject.rigidbody2D.AddForce((worldMouseUpPosition - worldMouseDownPosition)*jumpForceMultiplier);
readyToJump = false;
isFalling = true;
}
}
function OnCollisionStay2D(){
isFalling = false;
}
function OnMouseDown () {
if (isFalling==false){
worldMouseDownPosition = Camera.main.ScreenToWorldPoint (Input.mousePosition);
readyToJump = true;
}
if (Input.GetButtonUp("Fire1")){
readyToJump = false;
}
}
Thank you for your help. Any unrelated tips also welcome!