- Home /
two different collider in one script
hi everyone i have a problem in this script. i making a time system script with two different collider one is for the finish line the other is for pause the time. how do i put two different colliders in one script?
pause time:
function OnCollision (hit : Collider) {
Debug.Log("collision");
if(hit.tag == "clock") {
//Race is finished
isPaused = true;
}
}
finishline:
function OnTriggerEnter(other : Collider)
{
//var otherScript : ScoreScript = GetComponent(ScoreScript);
// If you have no other triggers,
// you can ignore the tag check.
if (!enabled || other.tag != "finishline")
return;
if (++score >= goal)
Win();
}
Answer by Meltdown · Sep 23, 2011 at 04:36 PM
Attach a script called GameManager to your Main Camera, and handle the pausing of your game from that. You can apply this same script to all your scene's Main Cameras and write it once. Use this GameManager script for any logic that is not specific to one scene.
For the finish line, create a prefab, and attach a seperate script to it, call FinishLine, and handle any collision with your finish line in that script. You can then drag your prefab everywhere that you need it, i.e into all your stages.
Cool please upvote and mark as answer if this solved your question.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Countdown Timer location 1 Answer
Making a fill take exactly n seconds to complete 2 Answers
timer starts in the menu scene 1 Answer
How to shape time however I want? 2 Answers