# A Random Entity

Discussion in 'Mapping Questions & Discussion' started by Algebraic, Aug 7, 2010.

1. ### AlgebraicL1: Registered

Messages:
34
Positive Ratings:
2
Hey, i was just wondering if there was any way to have an entity generate a random number...its hard to explain, but heres an example of a use for it:
You have 7 rooms, in room #1 there is a teleporter entrance.
Room numbers 2,3,4,5,6,7 (All named their numbers) have a teleporter exit.
So is there any way to make it so that the entrance will teleport a player to any of the other rooms at random? So, a player spawns and enters the teleporter and goes to room 3, another player spawns and enters into the teleporter and goes to room 6, etc.

2. ### Captain HatmanL1: Registered

Messages:
24
Positive Ratings:
6
The way I'd do it would be to use multiple instances of logic_timer, which can fire off at random intervals.

Turn on "use random time" and set your minimum random interval to 1 and your maximum random interval to any arbitrary number - say, the number of timers you intend to use +1. in outputs, use the output "OnTimer".

use a few of those to activate the exits, or set the target of the entrance, or turn on different entrances or whatever it is you're doing. It won't be completely random, but two players passing through a few seconds apart should wind up going to different rooms.

• Thanks x 1
3. ### AlgebraicL1: Registered

Messages:
34
Positive Ratings:
2
Thanks, that should work alright for what i have in mind.

It just seems weird that valve wouldn't have a "math_random" or something that generates a random number.

4. ### aalanaCurrently On: ?????

Messages:
3,077
Positive Ratings:
1,390
• Thanks x 2
5. ### Captain HatmanL1: Registered

Messages:
24
Positive Ratings:
6
heh, wish I'd remembered that.