- Home /
Other
Player stucks on ladder (with picture)
I have ladder script and it is work properly but when climbing down i have some bugs like the picture my player couldn't away from ladder i know i need add something stop the player when reach bottom to script but i dont know what it is. how can i fix this
Green is the ground and red is the player
This is the script;
#pragma strict
var ChController : Transform;
var heightFactor : float = 3.2;
private var inside = false;
private var FPSInput : FPSWalkerEnhanced;
function Start ()
{
FPSInput = GameObject.Find("Player").GetComponent(FPSWalkerEnhanced);
}
function OnTriggerEnter (Col : Collider)
{
if (Col.tag == "Player");
{
FPSInput.enabled = false;
inside = true;
}
}
function OnTriggerExit (Col : Collider)
{
if (Col.tag == "Player");
{
FPSInput.enabled = true;
inside = false;
}
}
function Update()
{
if (inside == true && Input.GetKey("w"))
{
ChController.transform.position += Vector3.up / heightFactor;
}
if (inside == true && Input.GetKey("s"))
{
ChController.transform.position += Vector3.down / heightFactor;
}
}
Answer by vintar · Jan 10, 2016 at 09:37 PM
You would need to check if the player is colliding with the ground and then stop moving down :
if (!grounded && inside == true && Input.GetKey("s"))
Can you add this my script because i don't have any idea how can i do this i am a newbie
Character controller has this property. You can just use this to check if character is grounded.
when i add that code on my script scene is crushes. might be a infinite loop or something like that i delete the code crush fixed.
Follow this Question
Related Questions
Accessing Colliders in IF statement from PARENT Object. 1 Answer
Slower Ladder 2 Answers
Building a Snap System, Need Help 1 Answer
How to make the player turn left or right only in desired places o edges and not everywhere ???? 0 Answers
How to detect when two gameObjects collide by name {java, 2d} 2 Answers