Hello,I am currently just simply using the standard fps controller.I am not a coder(even though I need to be)So I was wondering If I could get a simple ladder script that would move my fps controller up the y axis once I touch(collide) the ladder to work with a standard fps controller. Any feedback is appreciated, ;)
(1) Attach a box collider in addition to a mesh collider to your ladder object (name it "ladder"). In the Inspecter check the "Is Trigger" property in the Box Collider. It will be used as a trigger, and the following code uses this property. The Mesh Collider prevents the First Person Controller from falling through the ladder.
(2) Create a javascript and copy&paste the code below, and attach the script to the First Person Controller.
(3) I set the slope limit to 85, but you can change that howver you wish.
function OnTriggerEnter (other : Collider)
{
if(other.gameObject.name == "ladder")
{
transform.GetComponent(CharacterController).slopeLimit = 85;
transform.GetComponent("CharacterMotor").sliding.enabled = false;
}
}
function OnTriggerExit (other : Collider)
{
if(other.gameObject.name == "ladder")
{
print("leaving ladder");
transform.GetComponent(CharacterController).slopeLimit = 45;
transform.GetComponent("CharacterMotor").sliding.enabled = true;
}
}
You could use OnControllerColliderHit etc instead of OnTrigger functions- it's up to you. This is just one way I came up off the top of my head, and I can imagine various other methods. Hope it helps.