The Daily Click ::. Forums ::. Klik Coding Help ::. MMF 1.5 - Problem with creating new objects at the same time
 

Post Reply  Post Oekaki 
 

Posted By Message

Strife

Administrator
Der Dairy Crick

Registered
  21/11/2002
Points
  2305

VIP MemberGOTW AWARD! -Astro Dude - part 1 GOTM JULY - 2009 - 3RD PLACE!It's-a me, Mario!Has Donated, Thank You!I donated an open source project
23rd July, 2009 at 18:02:16 -

This is something that i've always had an issue with, one way or another. Say, for example, I have several "cannon" objects on the screen and I want them all to create a continuous stream of lasers in a circular motion. I have a condition that says something like this:

Always
- Create "laser beam" at (0, 0) from "cannon"
- Set direction of "laser beam" to dir("cannon")
- Set direction of "cannon" to dir("cannon") + 1

The "laser beam" object is using a Bouncing Ball movement in this example.

The laser beam will fire in a circle, just like I want to, when only one cannon exists. However, if more than one cannon is firing at the same time, only one cannon will behave like it should. The rest of the cannons will end up firing lasers in only one direction, regardless of what direction they're facing.

I've tried using fast loops, but the best I can do with them is getting two cannons to fire correctly. Is there a more efficient way of create objects at the same time and getting them to work like they should?

Edited by an Administrator

 

OMC

What a goofball

Registered
  21/05/2007
Points
  3334

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
23rd July, 2009 at 18:25:26 -

What did your fastloop setup look like? Was it similar to:

Start from Frame
>> Spread value 1 in alterable value A of Cannons

Always
>>Start loop number of cannons times

On loop
+Cannon alterable Value A = Loopindex
>>Create "laser beam" at (0, 0) from "cannon"
+Set direction of "laser beam" to dir("cannon")
+Set direction of "cannon" to dir("cannon") + 1

Or was it something else?


 

  		
  		

GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
23rd July, 2009 at 18:32:17 -

Flag 0 of object is off.
- set flag 0 on
- condition
- condition
- condition
-etc.

 
n/a

Strife

Administrator
Der Dairy Crick

Registered
  21/11/2002
Points
  2305

VIP MemberGOTW AWARD! -Astro Dude - part 1 GOTM JULY - 2009 - 3RD PLACE!It's-a me, Mario!Has Donated, Thank You!I donated an open source project
23rd July, 2009 at 20:30:34 -


Originally Posted by OldManClayton
What did your fastloop setup look like? Was it similar to:

Start from Frame
>> Spread value 1 in alterable value A of Cannons

Always
>>Start loop number of cannons times

On loop
+Cannon alterable Value A = Loopindex
>>Create "laser beam" at (0, 0) from "cannon"
+Set direction of "laser beam" to dir("cannon")
+Set direction of "cannon" to dir("cannon") + 1

Or was it something else?



It was almost like that, except that I put the Spread Value action in an Always event instead of Start of Frame. Your line of code did the trick, though. Thank you! And thank you for the alternative method, Gamester.

There's another thing that i'm wondering though... What if I wanted the laser beam objects to shoot particles in the same direction that they're facing? In other words, how would I add a second "layer" of simultaneous object creation?

I'm trying to think of how to describe it best... A practical example of how I want to use that is with something in another game i'm making. In this game, I have a variety of different projectiles the enemies can fire, but instead of using an individual object for each type of projectile (i.e. a "fireball" object and a "snowball" object), I use a single type of object and have it behave according to what animation sequence it's using (i.e. a "universal projectile" object with fireball and snowball animations). In addition, each projectile spits out particles at a constant rate, depending on what animation it's playing, so while your fastloop will work wonderfully with the projectiles themselves, the particles will still mess up until I learn out how to add a second layer of fastlooping.

Ideas? Cookies?

 

GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
23rd July, 2009 at 21:07:18 -

Dunno if im interpreting this correctly, but cant you just have it create particles while animation or animation direction = whatever?

animation fireball is playing
- create fire particle

animation snowball is playing
- create snow particle

should work with no loops ?_?

Or is the problem that you don't know how to make them travel in the same direction of the object?

Edited by GamesterXIII

 
n/a

Strife

Administrator
Der Dairy Crick

Registered
  21/11/2002
Points
  2305

VIP MemberGOTW AWARD! -Astro Dude - part 1 GOTM JULY - 2009 - 3RD PLACE!It's-a me, Mario!Has Donated, Thank You!I donated an open source project
23rd July, 2009 at 21:36:59 -

Without loops, the particles are created, but I can't set them to face a specific direction without having the same issue I had with the laser beam problem. In other words, "Set snowball particle direction" only affects the first snowball that was created, while all other snowballs shoot particles in the default direction instead of the direction I specified.

It's basically the same problem I had with the laser cannons, but instead of a static object shooting a projectile, it's a essentially a static object shooting a projectile shooting a projectile... if that makes sense. ^^;

 

GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
23rd July, 2009 at 21:53:31 -

Okay. I'm assuming you're using create an object instead of shoot an object? If not I think you could adjust this a bit to work with it.

If so you could try this.

Whatever condition creates particles
-create particle at fireball x,y
-set particle value A to fireball value A

-I thiiiiiink this would work. You'll have to test it

this assumes that you spread 1 into value a of the fireball at the start.

Value a of particle = value a of fireball (make sure you use compare two general values for this!)
+ flag 0 of particle is off
-set particle flag 0 on
-set particle direction to direction of fireball.

sorry if this is a little awkward, im posting from my shop and i'm a bit busy atm.





Edited by GamesterXIII

 
n/a
   

Post Reply



 



Advertisement

Worth A Click