Actor move to random other actor?

Hey guys I'm having some trouble coming up with a way to do this...

I have a spawner that spawns an actor every so often and I want that actor to go to one out of the other 10 actors randomly.
Such as actor A will spawn and go straight to actor 1, 2, 3, 4, 5, 6, 7, 8, 9, or 10 randomly.
As soon as actor A hits the actor it was headed towards, I want that actor to be removed from the list of available actors to travel to.

So lets say... actor A spawns and randomly goes to actor 4. A spawns again and randomly goes to any other actor except actor 4. This will continue until Actors 1 through 10 are all gone.

Any ideas?
Hopefully this makes sense!

Answers

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Are the actors 1 through 10 moving? Or do they keep their same positions the entire time?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited January 2017

    Here's a way to do it if they are NOT moving:

    Actors #1-10

    (manually assign them self.ID values of 1 to 10)
    Change table value in row self.ID and column 1 to self.Position.X
    Change table value in row self.ID and column 2 to self.Position.Y

    Actor A

    Change self.row to random(1,tableRowCount(tableName))
    Change self.nextX to tableCellValue(tableName, self.row, 1)
    Change self.nextY to tableCellValue(tableName, self.row, 2)
    [move to self.nextX, self.nextY]
    [remove table row #self.row]
    [repeat until only one row remains]

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • MatschzMatschz Member Posts: 7
    edited January 2017

    Actors 1 through 10 keep the same position the entire time.

    I'll try this out. Do you have an pic where I can see these settings in app? I'm just getting back into this and have to refresh my memory :P

    Actors 1 through 10 also all have the same tag. I'm not sure if its possible or better to make actor A go towards that tag randomly or go to actor 1 through 10 randomly.

    Thanks a ton for the replies!

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @Matschz said:
    Do you have an pic where I can see these settings in app? I'm just getting back into this and have to refresh my memory :P

    I don't, sorry.

    Actors 1 through 10 also all have the same tag. I'm not sure if its possible or better to make actor A go towards that tag randomly or go to actor 1 through 10 randomly.

    The latter.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • MatschzMatschz Member Posts: 7

    Awesome thank you for the help!

  • MatschzMatschz Member Posts: 7

    Having trouble understanding how all of this is done. Can someone give me a break down how to do this? Any help would be so appreciated!

    Actors #1-10

    (manually assign them self.ID values of 1 to 10)
    Change table value in row self.ID and column 1 to self.Position.X
    Change table value in row self.ID and column 2 to self.Position.Y
    Actor A

    Change self.row to random(1,tableRowCount(tableName))
    Change self.nextX to tableCellValue(tableName, self.row, 1)
    Change self.nextY to tableCellValue(tableName, self.row, 2)
    [move to self.nextX, self.nextY]
    [remove table row #self.row]
    [repeat until only one row remains]

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited January 2017

    When I say manually I mean that you create an attribute and then double-click on each instance of the actor within the scene and change the value of that attribute in the actor's attributes list. You're setting the default value of the attribute. It doesn't require a behavior.

    The table would contain each actor's x position in column 1 and Y position in column 2. If you haven't worked with tables before, check out tutorials (e.g. Google gamesalad tables and click on the Videos tab).

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • MatschzMatschz Member Posts: 7

    Ok so it looks like this wont work as actor A isn't on scene initially and gets spawned in random position repeatedly.

    Unless the only way to get this to work is to forget the spawner altogether and put multiple actor A on screen in the beginning and upon Actor A being destroyed, move it to another random position in the scene?

    I do prefer the spawning route if possible.

    Thanks again for all your help!

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    It shouldn't matter if actor A is spawned or not. The rules I provided above are going to direct it to move to a random position once it's in the scene.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.