Randomly spawn a trigger area

Hi, im making a horror game where you walk around in a maze (randomly generated) and the main goal is to get out.
Im almost finished but i want to spawn a trigger area somewhere in the maze so that i can have a jumpscare of some sort. is this do-able? (Giggity)

This here will create a Random Collider in a random place.

Step 1. Create an Empty GameObject, rename.

Step 2. Add a Collider to it

Step 3. Create a new Prefab, and add the new GameObject ( be sure to have it in folder “Resources” . It can be a child of any folder. Just kind in mind what directories you are using. )

Step 4. Execute the code here

function CreateRandomCollider ( )
{
     var RandomPos : Vector3 = Vector3 ( Random.Range(min,max), Random.Range(min,max), Random.Range(min,max) ) ;
     var rancollinstance : GameObject = Instantiate ( Resources.Load("PrefabColliderYouCreatedWithoutExtension"), RandomPos, Quaternion.identity ) ;
}

Set your ‘min,max’, and execute the code above.

Something to kind in mind though is that the script does not provide any kind of support for making sure the collider is spawned on the terrain/mesh. That part, you will need to do.

I hope this helps you with your issue, and feel free to ask any questions if this has not solved your issue.

Thanks for supporting Unity3D

~Montray