The Daily Click ::. Forums ::. Klik Coding Help ::. Using same objects for multiple enemies?
 

Post Reply  Post Oekaki 
 

Posted By Message

siven

I EAT ROCKS

Registered
  03/11/2008
Points
  604

Wii OwnerVIP Member
6th February, 2014 at 06/02/2014 21:18:07 -

So im wanting to use the same 2 objects for all the enemies in one frame. they will be spawning from random points on the map, and they will automatically head your direction. the two objects are an invisible "detector" and a overlaying character object. the detector is given the Enemy Qualifier, and upon bullet overlapping with the Detector object subtract damage of bullet from alterable value A(health) of detector. its supposed to destroy the detector and the correct animation sprite for ONLY the enemy you killed. its set on a loop that plays every so many seconds that starts a fast loop that spawns 1 enemy and 1 enemy detector, and then spreads the value 0 through alterable valueB(ID). im having the issue of when i destroy one detector, it destroys just that detector, but will destroy all of the visible animation objects. i dont understand why this is happening, the destroy line reads If ID of Animation object is equal to ID of Detector then destroy both. am i doing something wrong when im spreading the values? at what point should i spread? and how frequently? because enemies will be spawned constantly until you die. im not certain whats causing this. ill provide source if it is absolutely needed but i would prefer not to.

 
[Game design makes my brain feel like its gonna explode.]

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
6th February, 2014 at 06/02/2014 22:04:36 -

I can't say what the problem is without seeing your code, but...

Personally, I prefer to use embedded collision detectors, instead of separate detector objects, because they make this kind of thing so much simpler.

Failing that, I also prefer not to use spread values for this kind of thing, and instead just let MMF2 match the objects itself. Basically, something along the lines of this:

+ Detector: Health <= 0 or whatever...
-> Detector: Set DestroyMe to 1

+ Always
-> Sprite: Set DestroyMe to DestroyMe("Detector")

+ Sprite: DestroyMe = 1
-> Destroy Sprite

+ Detector: DestroyMe = 1
-> Destroy Detector


eg. http://sdrv.ms/1b6jBr6
I'm not saying that's the only "right" way to do it, but I find it simpler.

 
n/a

siven

I EAT ROCKS

Registered
  03/11/2008
Points
  604

Wii OwnerVIP Member
7th February, 2014 at 07/02/2014 00:58:39 -

So i changed it from spreading value whenever an enemy spawns to Always spreading value in ID and that seemed to fix it. im still having a few issues with certain events affecting the enemies as a group instead of individuals, but its nothing major. thanks for the help though.
whats an embedded collision detector?
also i tried letting mmf2 do it on its own but i was having an issue with it matching them correctly, also killing an enemy either destroyed all sprites and only 1 detector, or it would not destroy the sprite at all and cause the sprite to teleport to the next available detector, if no more detectors were visible it would just sit in the same spot till a new detector was spawned. i fixed that but im still having an issue with killing multiple enemies at the exact same time. it will destroy one of them, but the remainder will still be stuck behind, not too sure why.

 
[Game design makes my brain feel like its gonna explode.]

Pan-tosser



Registered
  24/10/2008
Points
  520

Has Donated, Thank You!
7th February, 2014 at 07/02/2014 02:31:18 -

I had a problem just like yours with my own current project. I stopped using spread value all together. Instead i use the for each object.

the reason could be that the spread count always changes. if their are three objects spawned. Next if you spawn up to four. then what was three is now four and the new one created holds the lowest value. So its a pain in the ass to match up anything with a spread value.

this was the problem my project had. So i ended up changing to the for each object. I tested objects with it. To see if they belonged to a for each alive group, and if a bullet hits them i remove them from the alive group. When the program loops again a for each loops checks all the enemies in a loop and deletes the ones not in the alive group.

You might already know that about spread values, but i just wanted to put it our their anyways. Just in case it can help anyone.

Edited by Pan-tosser

 
https://www.facebook.com/nathon.brown.7

siven

I EAT ROCKS

Registered
  03/11/2008
Points
  604

Wii OwnerVIP Member
7th February, 2014 at 07/02/2014 05:08:23 -

I dont have the for each object. where can i get that at? im not having any fun using the spread value, its "hiccups" are kind of annoying lol.

 
[Game design makes my brain feel like its gonna explode.]

Pan-tosser



Registered
  24/10/2008
Points
  520

Has Donated, Thank You!
7th February, 2014 at 07/02/2014 23:11:29 -

The only place i know where to find any extensions any more is with the extension view program.

http://softadvice.informer.com/Extension_View_2.15_Mmf2.html

 
https://www.facebook.com/nathon.brown.7
   

Post Reply



 



Advertisement

Worth A Click