Page 1 of 1

How do you make an actor appear ramdomly on a region?

PostPosted: Sun Nov 16, 2008 5:46 am
by ded15
I'd like to know how do you make an actor appear randomly on an entire game?

Re: How do you make an actor appear ramdomly on a region?

PostPosted: Sun Nov 16, 2008 10:47 am
by Kalladdolf
On the create actor event put the following code:
Code: Select all
x = rand(200);
y = rand(200);


in this case, the actor will appear randomly between x 0 - 200 and y 0-200.

Re: How do you make an actor appear ramdomly on a region?

PostPosted: Mon Jan 05, 2009 1:23 pm
by Bee-Ant
That code will only work for any actor arround x 0-200 and y 0-200, what if you want to put your actor at x,y(500,1500)???
Use this code to make its appear randomly at any coordinate
Code: Select all
x-=rand(400);
x+=rand(400);
y-=rand(400);
y+=rand(400);

:D

Re: How do you make an actor appear ramdomly on a region?

PostPosted: Tue Jan 06, 2009 12:19 am
by DST
x=rand(800)-400; :D

Go one step further, with a wireframe/filled region actor, script called from the wireframe/filled actor:

otheractorname.x=rand(width);

Many users don't realize, you can use the variables 'width' and 'height' for any actor. ( I don't think its mentioned in the documentation).

Re: How do you make an actor appear ramdomly on a region?

PostPosted: Tue Jan 06, 2009 12:31 pm
by Bee-Ant
DST wrote:x=rand(800)-400; :D

Ah yes, thats what I mean...
you forgot something
Code: Select all
y=rand(800)-400;
:P
using width just move that actor as far as it's own width...