How to set an unique number for the same actor

FirstDanFirstDan Member Posts: 208
edited October 2012 in Working with GS (Mac)
Hi all

I have a single actor that I'm spawning 6 times by the following
Logic.
If actor count < 7 spawn actor

How can I set an count to uniquely identify these actors for eg. Actor 1 =1, actor 2 =2

Is this possible without unlocking the actors?

Much appreciated

Dan

Comments

  • gamesfuagamesfua Member Posts: 723
    Can you give an example or reason why you want this done? I'm fairly new to GS but that info may help me give some kind of suggestion. Personally, and again I'm new here, but from the info you've provided, it appears like you may have to set up a couple of rules. Something that almost looks like this...
    EXAMPLE: In this example 5 bad guys have been spawned. A 6th is about to be spawned NOW...
    In the actor, a rule would say something like, From beginning of spawn, if actorcount is 5 then change attribute "self identity" to 6. (Self identity is an attribute I would have created-perhaps in integer).
    I haven't tested this logic and there's a solid chance it may not work, but that's kind of the angle I'd be testing out.
    Another possible direction I would go in, is to simply make 7 actors and give them unique identities. When they die or whatever, don't destroy them, simply put them off screen and wait to be respawn later.
    So that may be another way of doing it too. Recycling actors is also a good idea for RAM consumption and performance.
    Hope this helps.
    Again, new here, so don't take my word for it.
  • FirstDanFirstDan Member Posts: 208
    The reason is because Im Developing my game on 1Scene and I'm spawning actors at the different times, there no point in spawning them initially as if I did it this way, performance would be awful.
  • gamesfuagamesfua Member Posts: 723
    No I'm saying what is the need to identify each actor. I understand not wanting to spawn actors like crazy. But I'm curious if there is a purpose to needing them each identified? If it's crucial to have them identified try one of the tactics I provided above until someone else may give a better suggestion. If you never go above 7 actors on one screen at the same time, then perhaps just create 7 different actors (with unique names, etc.) And just recycle them over and over again. Win win. You get good performance and you get the unique identification you're after. Recycling (in case you don't know what it is), is not destroying an actor, it's temporarily placing it off screen and then bringing it back on screen when needed. So for instance if HERO shoots bullet at ENEMY. Don't DESTROY ENEMY, instead say, When Enemy Overlaps Bullet, Change self position x and y of Enemy to X (whatever position coordinates off screen you want). Then you can do the same (but in reverse) to bring the actor back on screen when needed.
  • ashtmjashtmj Member, PRO Posts: 405
    add a global attribute called enemy# and a attribute within the enemy actor called "my#" when he spawns have two rules, change "self.my#" to "game.enemy#" then change "game.enemy#" to "game.enemy#"+1 (both rules go inside the enemy actor)

    that will give them each their own number
  • gamesfuagamesfua Member Posts: 723
    Wow nice ashtmj!
  • FirstDanFirstDan Member Posts: 208
    @ashtmj - spot on, thanks
    @anatomyofdreams - thanks also for your thoughts :)
  • gamesfuagamesfua Member Posts: 723
    No problem, and good luck with your game! :)
Sign In or Register to comment.