Adding a dot on a minimap for multiple spawned enemies

scitunesscitunes Member, Sous Chef Posts: 4,047
edited November -1 in Working with GS (Mac)
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

  • quantumsheepquantumsheep Member Posts: 8,188

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Yeah,

    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?
  • quantumsheepquantumsheep Member Posts: 8,188
    Ah, I see what you mean now! Sorry!

    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

  • JaxterJaxter Member, PRO Posts: 398
    cool tut..
  • JaxterJaxter Member, PRO Posts: 398
    quantumsheep maybe u can help me in this point? http://gamesalad.com/forums/topic.php?id=740
  • quantumsheepquantumsheep Member Posts: 8,188
    I'd love to help, Jaxter, but none of my games use the accelerometer, so I've not had much experience in implementing it/fixing issues with it.

    Sorry mate :(

    QS

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Whoa! I just got forum jacked! Sneaky!

    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?
  • TobyToby Member Posts: 478
    I've have done this for my Game Elerium 115. Use the same process for the main player basically.

    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.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    So there is no shortcut? I really have to create 40 new attributes for 20 new enemy actors and 20 new enemy map dot actors?

    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!
  • JGary321JGary321 Member Posts: 1,246
    Mwuahah, JGary to the rescue (I think)

    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
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Thanks! I am a bit confused though. Here are a couple of questions to help me make sense of your response.

    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!
  • JGary321JGary321 Member Posts: 1,246
    You NEED 1 actor. Create however many instances you need. Same with the dots. They are all based off 1 actor, with multiple instances. On the actor you put a constrain to the game.attribute x, y that you make up. Like game.Monster Y & game.Monster X. Then on the minimap dot, constrain game.Monster x,y / 4.

    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.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Thanks! I can't wait to try it!
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Tried it and my whole game and even the gs software simply froze. I still can't wrap my brain around how two atributes can keep track of 20 different xy coordinates at the SAME time. The enemies in my game are all loaded in the game from the time the scene starts. It would make sense in a game that has one enemy at a time being spawned, but that's not how my game works.
  • JGary321JGary321 Member Posts: 1,246
    Mine are spawned 1 at a time, so MAYBE that makes a difference, no idea. This is how I do my HP bars for my game & also range indicators are done the same way. But again they are spawned one at a time.
  • TobyToby Member Posts: 478
    I'm not sure if the spawning method will work because if the enemies are all spawned off the same actor and they share a game (global) attribute which changes Eg: this enemy has been shot.... they all die.

    Or am I missing something in the way I design my game too?
  • JGary321JGary321 Member Posts: 1,246
    It works as far as keeping their X/Y. But it does not work for HP or anything like that. I have no idea WHY it works, common sense would tell me it wouldn't, but for some reason it does. I can verify b/c this is how my game works =)
Sign In or Register to comment.