Urban Wars
April 19, 2024, 05:38:32 am
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Welcome, here you will find all the information on Urban Wars
 
  Home Help Search Staff List Login Register  

Randomly spawning a different sprite

Pages: [1] 2
  Print  
Author Topic: Randomly spawning a different sprite  (Read 918 times)
DukeInstinct
Administrator
Lieutenant
*****
Posts: 120


The ArchDuke


View Profile WWW
« on: April 23, 2010, 09:57:39 pm »

The number you get back from the built in random function will always be between 0 and 1. However, if you wanted a number between 0 and 3 you could just multiply the number you get back from random() with 3.

So you could also do this if you wanted to:

Code:
float Rand;

Rand=random(); // returns a number between 0.0 and 1.0
Rand*=3;

if (Rand<=1)
setmodel(Entity, Sprite Name);
else if (Rand<=2)
setmodel(Entity, Sprite2 Name);
else
setmodel(Entity, Sprite3 Name);
Report Spam   Logged



Urban Wars Coder/3d Modeler/Animator



Pages: [1] 2
  Print  
 
Jump to:  


Get your own Chat Box! Go Large!
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum

Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy