Adding a dot on a minimap for multiple spawned enemies
scitunes
Member, Sous Chef Posts: 4,047
Is there any way to have dots appear on a minmap that follow the movements of a bunch of copies of the same enemy actor that are being spawned throughout the game?
Comments
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
I've read the wiki closely and it is working great for my main player. But I have copies of the same enemy actor throughout my platform style game and I do not know how to have a separate dot on the minimap for each enemy. I can't figure out how to have a separate dot for each enemy without creating 20 unique actors. If I made 20 unique actors it would be very easy, but it would seem like that would eat a lot of memory. Is having unique enemy actors the only solution?
I'm afraid I'm not much help on this one - the game I have that uses a mini-map has 8 enemy actors on-screen at once, preloaded, and they're all unique
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
Sorry mate
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
Anywho... about the whole mini map thing...
Anyone know how much memory it would take up to have 20 unique actors as compared to 20 copies of the same actor?
Define a set of X & Y game.attributes for each enemy or object (integer)
Enemy1X
Enemy1Y
.....
Constrain these X&Y's to each enemy actor.
Create your minimap dots as unique actors and within each dot actor:
Add a Constrain with self.position / Enemy1X
At the end of the Enemy1X you will need to (Divide /) the size of your fullsize map by the size of your minimap. This will put your dot on the minimap and make it move and scroll the correct distance relative to the minimap size.
Say my map is 1000 pixels wide and high and my minimap is 100 pixels wide and high.
the math would be .... 1000 / 100 = 10. The minimap is 10% the size of the actual full size map.
So the the constrain XY on our map dot behaviour would look like this:
Constrain with (self.position) / ( Enemy1X/10 )
Constrain with (self.position) / ( Enemy1Y/10 )
Now this is done and you've added your dot to the stage you need to offset the dot on the 480x320 resolution screen to overlay the dot on the minimap. Eg my minimap is top RHS of the screen. If you do not put the offset on the dot will be stuck in the bottom LHS corner.
Add an offset to the XY on the end of your ( Enemy1X/10 ) so it looks like this (Enemy1X/10+330)
Adjust the numbers on your offsets until the movement looks correct on the minimap when your enemy moves around.
Will all of this cause my game to come to a screeching halt? Can unique rules be added to separate instances of the same actor, or must they be unique actors?
Thanks!
I do something similar for HP bars in my game. This is the easiest way. In the actor Constrain the units X/Y to a game.attribute. Then in the unit create a rule that Spawns Actor - Map Dot.
That way when your enemy is created it constrains the X/Y & spawns the dot.
Under the dot Constrain X/Y to your mob actor 1/4, like they say in the tutorial.
I found out that you only need 1 game.attribute to keep track of the X/Y of ALL instances of any mob. I used to create an X/Y of every mob type. But you don't need to. So even if you create multiple instances it will still constrain it to each instance.
-JGary
1) How many unique enemy actors do I create? 20 or 1 with 20 instances?
2) How many unique dot actors on the map do I create?
3) Does the constrain attribute behavior go on the dot actor? ie what behaviors go on the dot actor?
Separate Question-
I have recently read that spawning uses a lot of memory. Is that true if it is just a 4px x 4px actor with no image (just a color)?
Thanks for the help!
As far as memory spawning does take a lot of memory, however, i've noticed my game only hiccups when there's a lot of rules in the actor. Your dots won't take much, b/c they will only have a few rules. My enemy actors do tend to cause a slight hiccup, but my spells cause no hiccup even if I spam them. My enemy actors have more rules though. Hope this helps. It's a very useful trick.
Or am I missing something in the way I design my game too?