- Home /
Making a "vault over an obstacle" script
I'm making a Le Parkour game. I want to make the game mechanics first, so I want to make vault script first. So I modelled a simple object that I want to vault over, I made an animation of it, and I inserted two boxes (I want them as colliders): there is a one on one side and there is a one on the other side. I want to enable the script that will let the player activate the vault animation by pressing "space", and I want to enable that script while standing on a collider. So I made two scripts: one activating the animation on space button and one activating the script that activates that first script. I assigned that first one to the Player and that second script to the Collider. But when I play, it doesn't activate the script assigned to the Player. Here is the script of Collider, tell me what is wrong in it:
function OnTriggerEnter (other: Collider){
if(other.gameObject.tag == "Player"){
pv1 = GameObject.Find("First Person Controller");
pv1.GetComponent(playervault1).enabled = true;
}
}
function OnTriggerStay (other: Collider){
if(other.gameObject.tag == "Player"){
pv1 = GameObject.Find("First Person Controller");
pv1.GetComponent(playervault1).enabled = true;
}
}
function OnTriggerExit (other: Collider){
if(other.gameObject.tag == "Player"){
pv1 = GameObject.Find("First Person Controller");
pv1.GetComponent(playervault1).enabled = false;
}
}
Your answer
Follow this Question
Related Questions
Scripting Help 1 Answer
Adding a box collider to an object in csharp script 3 Answers
Gradually change distance fog over time with a collider object. 1 Answer
Jump with a wallrun 0 Answers