- Home /
Need help with ladder script
I need help with a Ladder Script.
i have this: 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;
}
}
But it gives me the Error: "sliding" is not a member of "UnityEngine.Component"
Answer by whydoidoit · Mar 16, 2013 at 12:25 PM
You should use:
transform.GetComponent(CharacterMotor).sliding.enabled = true;
The version with the "" just returns a Component, which you would have to cast to be the right type. The one without the "" does that for you.
Good the error is away but i cant climb up the ladder?
Your answer
Follow this Question
Related Questions
Trying to Make a Topdown, 3rd Person Ladder 0 Answers
switching gun on screen with gun you pick up. 3 Answers
Wrapping A Game Map.. 4 Answers
How to draw 3D text from code 4 Answers
Trying to get score counter... 2 Answers