how do i make multiple objects out of one

Non-platform specific questions.

how do i make multiple objects out of one

Postby toptimcat » Tue Sep 04, 2012 4:08 pm

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.
toptimcat
 
Posts: 4
Joined: Thu Aug 30, 2012 2:01 pm
Score: 0 Give a positive score

Re: how do i make multiple objects out of one

Postby toptimcat » Tue Sep 04, 2012 5:17 pm

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..
toptimcat
 
Posts: 4
Joined: Thu Aug 30, 2012 2:01 pm
Score: 0 Give a positive score

Re: how do i make multiple objects out of one

Postby skydereign » Tue Sep 04, 2012 7:27 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: how do i make multiple objects out of one

Postby toptimcat » Wed Sep 05, 2012 7:52 am

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.
toptimcat
 
Posts: 4
Joined: Thu Aug 30, 2012 2:01 pm
Score: 0 Give a positive score

Re: how do i make multiple objects out of one

Postby toptimcat » Wed Sep 05, 2012 10:27 am

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.
toptimcat
 
Posts: 4
Joined: Thu Aug 30, 2012 2:01 pm
Score: 0 Give a positive score

Re: how do i make multiple objects out of one

Postby skydereign » Wed Sep 05, 2012 10:18 pm

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;
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron