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![alt text][1]
[1]: /storage/temp/61644-ladderfail.png
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;
}
}
↧