Page 1 of 1

how do i make multiple objects out of one

PostPosted: Tue Sep 04, 2012 4:08 pm
by toptimcat
i was wondering how i can make multiple enemies out of just one. I have seen it be done before but unfortunately i am new here and when i saw it being done i didn't understand a thing about it. I want to know how to do this as i have started a small project that involves you having to dodge oncoming rocks that are randomly hurling towards you. i have seen it on a helicopter game remake where the green blockade is out of sight but appears multiple times during gameplay and on random routes. any help would be appreciated, thanks.

Re: how do i make multiple objects out of one

PostPosted: Tue Sep 04, 2012 5:17 pm
by toptimcat
okay, so after some deeper digging, i have found that you can use y = range and then some equation which just looks jibberish to me..

Re: how do i make multiple objects out of one

PostPosted: Tue Sep 04, 2012 7:27 pm
by skydereign
Do you know what clones are? You can use the CreateActor function to create new instances of any actor. So, if you wanted to create 10 of your projectiles call the CreateActor for the projectile actor. Each clone will have its own variables (actor variables such as position and velocity) but will contain the same events and actions. The y = range code that you mentioned doesn't seem to apply at all to what you say you are trying to do. But clones on the other hand are how you make multiple instances of a given actor in gE.

Re: how do i make multiple objects out of one

PostPosted: Wed Sep 05, 2012 7:52 am
by toptimcat
Thanks for this, i wasn't aware that clones could still have all their own variables.. Im not really sure what i saw on that guys code but it worked, ill paste the code when im next on the project.

Re: how do i make multiple objects out of one

PostPosted: Wed Sep 05, 2012 10:27 am
by toptimcat
is there a way to make the rocks move on the x axis at completely random speeds ? it would seem a bit pants if i created a game that had rocks flying at you the same way everytime you played it.

Re: how do i make multiple objects out of one

PostPosted: Wed Sep 05, 2012 10:18 pm
by skydereign
You can use the rand function to get random values in gE. In your case you want to set xvelocity to some random value. The function returns a value between 0 and the number you pass it. So the following would set xvelocity in the range of 1-4.
Code: Select all
xvelocity = rand(3) + 1;