script works in every trigger instead of one
Alright.. so i want to make a script that will allow the player to climb when in a certain trigger instead of jumping and another one with vaulting (parkour game mostly). But the thing is the vault works in both the vault trigger and climbing trigger and the same with the climbing.. here's the script and would love if someone could fix it for me :) #pragma strict
var animator : Animator;
var climbTrigger : Collider;
function OnTriggerStay (climbTrigger) {
animator.SetBool("Jump", false);
if (Input.GetKeyDown("c"))
{
animator.Play("Climb");
}
}
function OnTriggerExit (other: Collider) {
}
Answer by vintar · Jan 15, 2016 at 10:20 PM
Maybe set a bool to check :
var animator : Animator;
var climbTrigger : Collider;
var isClimbing : bool
var isVaulting : bool
function OnTriggerStay (other : Collider)
{
animator.SetBool("Jump", false);
if (Input.GetKeyDown("c") && !isVaulting)
{
animator.Play("Climb");
isClimbing = true;
}
if(Input.GetKeyDown("v") && !isClimbing)
{
animator.PLay("Vault");
isVaulting = true;
}
}
function OnTriggerExit (other: Collider)
{
isClimbing = false;
isVaulting = false;
}
so i tried it and my unity says this "climbScript1.js(3,19): BCE0018: The name 'bool' does not denote a valid type ('not found'). Did you mean 'UnityStandardAssets.Vehicles.Ball.Ball'?"
also..wouldnt it be easier if i do 2 different scripts and put them on each of the triggers and check which one has the tag "Player" in them?
So i changed some stuff and fixed some mistakes you made in the script like having PLay ins$$anonymous$$d of Play and some other stuff and i acctually got it to work ^^. I really thank you :D