x


Randomly selected rooms

I'm making a horror game on unity that I started not too long ago where enemies pop out at you. I realized people could just memorize where the monsters are, making it only scary the first time. I was wondering if there was a code or something to make it possible to randomly choose rooms that I have already made, similar to SCP-containment breach. I would like to have it so there is about 5 random rooms, and some rooms look the same, except have the monster in it (So you can't memorize what room they spawn in either). I started unity about a week ago, and i'm still horrible at coding, so could someone start me off with some advice? Thanks in advance :D

more ▼

asked Jun 24 '12 at 10:11 PM

Cbjfan1 gravatar image

Cbjfan1
42 4 17 29

Also, is there a way to create a seed generator?

Jun 24 '12 at 10:08 PM Cbjfan1

You could put more spawners in a room and make them randomly spawn at each of them, sure ppl can memorize them too but if you put more than 3 in each room they might forget where they spawn :)

Jun 24 '12 at 10:25 PM multinfs

Yeah, but the thing is some of these creatures teleport you, and others kill you + You don't have a gun (To make it more scary :D). So having them spawn almost every room would be a deathtrap

Jun 24 '12 at 11:13 PM Cbjfan1
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

You can have a script that uses Random.Range(); to choose the rooms. For example:

int roomNumber = Random.Range(1,5);

if(roomNumber == 1){
     Insantiate(monster, roomOne.position, roomOne.rotation);
}
else if(roomNumber == 2){
     Insantiate(monster, roomTwo.position, roomTwo.rotation);
}
else if(roomNumber == 3){
     Insantiate(monster, roomThree.position, roomThree.rotation);
}
else if(roomNumber == 4){
     Insantiate(monster, roomFour.position, roomFour.rotation);
}
else if(roomNumber == 5){
     Insantiate(monster, roomFive.position, roomFive.rotation);
}
more ▼

answered Jun 24 '12 at 10:31 PM

Overlord gravatar image

Overlord
484 67 78 88

Would this script go in a spawner or something? Sorry for the nooby question

Jun 24 '12 at 11:11 PM Cbjfan1

Whoa whoa whoa

Use arrays!

var room : Transform[];

roomNumber = Random.range(1,5); Instantiate(monster, room[roomNumber].position, room[roomNumber].rotation);

Jun 25 '12 at 01:29 AM Loius
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x441
x62

asked: Jun 24 '12 at 10:11 PM

Seen: 321 times

Last Updated: Jun 25 '12 at 01:29 AM