I dont know if this is the right place for me to ask this, but can somone give me a tutorial on colliders? i have alreayd tried all the ones on unity3D.com cand they dont work. im looking for a script that would set the “EnteredTown” boolean variable to true when my character collides with a specific object, towngate. please help :0
So there’s a couple of ways you can approach it.
OnTriggerEnter
OnCollisionEnter
CheckSphere
OverlapSphere
You have to decide which on works for you.
It sounds like you need to use the OnTriggerEnter
So your script would look something like this
function OnTriggerEnter (other : Collider)
{
//Get the Component on the player then set the boolean to true
other.GetComponent(Player).enteredTown = true;
//Destroy the trigger so the event only happens one time
Destroy(gameObject);
}
i tried all that. it didnt seem to work. what i want is a code to add to the script attached to my town gate that will set the EnteredTown bool to true, but it dosent seem to work…
NVM, fixed the problem:
function Update (){
var dist = Vector3.Distance(TownGate.position, Player.position);
if (dist < 10) {
Enteredtown = true;
}
}
Maybe the istrigger button wasn’t on…
Anyways, glad you found a different approach
Sincerely
Jacob Griffith