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();

}

1 Answer

1

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.