Spawn 5 Actors and Give Each Actor a Unique Number Between 1-5

robert.mccarthyrobert.mccarthy Member Posts: 165
edited February 2012 in Working with GS (Mac)
Hi All,

I have 5 actors, and each has an internal/unique attribute called 'myNumber'.

What I want to do is:

When these 5 actors are spawned, change the internal/unique attribute of each actor to a unique number between 1-5. if another actor has the same number then change it to another straight away.

Basically I want to assign a unique number to each spawning actor within a range.

Thanks,

Comments

  • GnomerGnomer Member Posts: 292
    You would have to have it linked to a game attribute as there is no way of one actor communicating with another actors internal attributes.
  • robert.mccarthyrobert.mccarthy Member Posts: 165
    Can you/someone help a little further please? We have been sat here for a few hours and lots of pseudo code on paper and it is not yet there! lol
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Yeah I have done something in the past that does that. I'm not sure if I still have any of the project. I'll look around when I get home tonight and see. Gnomer is on the right track though. You will have to base it all on game attributes.
  • robert.mccarthyrobert.mccarthy Member Posts: 165
    Hi Tenrdrmer,

    Thanks for this. Can you PM me anything you find please (if you can PM in this, I have never looked to use it before)??
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    Use tables

    On your spawner, have it randomly assign a number to a global attribute called tableRow. Then spawn your 5 actors.

    in each actor have a rule that reads from one column of a table on row tableRow

    And in your table, randomly prefill the tables with the information
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    That's a really good idea Jon. Much better than what I did 6+ months ago.
  • MotherHooseMotherHoose Member Posts: 2,456
    you can also change the name of a spawned actor … so you really don't need the added attribute
    same for tags

    gameAttribute … index type … spawnCount

    before each spawn on the spawner
    changeAttribute: game.spawnCount To: game.spawnCount+1

    on each spawnedActor 1st behavior
    changeAttribute: whatever you want to change To: game.SpawnCount

    @};- MH
  • CloudsClouds Member Posts: 1,599
    @Gnomer

    "You would have to have it linked to a game attribute as there is no way of one actor communicating with another actors internal attributes."

    Just unlock the actor when it's in the scene and you can access all the attributes of all the other actors.
  • GnomerGnomer Member Posts: 292
    @tynan ... whaaat? haha I never knew that, cheers :D
Sign In or Register to comment.