Changing Spawned Actor Attributes

jasonpbrucejasonpbruce Member Posts: 35
edited November -1 in Working with GS (Mac)
How do I change a actor that gets spawned onto a scene to change it's attribute relivent to the current scene? For example I have a spawner creating enemy fire... everytime one gets destroyed it should change enemy count -1 for the enemies in the scene. Problem is when I go into the actor prototype it doesn't give me an option for "current scene" attributes. I only get that option when the actor is edited in the scene. Any thoughts?? Thanks!

Comments

  • Geta-VeGeta-Ve Member Posts: 18
    I realize that this post is quite old at this point, but, the question is pertinent to me. I am trying to figure out how to change the velocity of a spawned actor.

    Specifically, I have 5 spawn points, and I want them all to spawn an actor moving in separate directions (ie, 2 spawn points will send the spawned actors in the negative X axis, and the other 3 will send them positive X)

    If you need more clarification please ask. :) Thank you!
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    One way is to communicate with the spawned actors through the use of a game attribute:

    Spawner actor
    ------------
    Change Attribute game.spawnDirection (angle) to [some value]
    Spawn Actor [Moving actor name]

    Moving actor
    -----------
    Change attribute self.myDirection (angle) to game.spawnDirection
    Move [some speed] [game.myDirection for the direction]

    Not sure if that all makes sense but it works and I've used it to great effect in my health bar demos in the Spare Code Dump It Here thread.

    If you have questions, explain a bit more about what you're trying to do first. It sounded to me like you wanted to spawn five actors and have them move in set (non-random) directions once they spawn.

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

  • Geta-VeGeta-Ve Member Posts: 18
    Hey there tatiang! That method actually works quite well! A workaround I was using (that was leading me to some issues) was to detect whether the spawned actor was at X position and then move left or right.

    However, I think your method is alot cleaner and more robust. :)

    Thanks tatiang! I appreciate your quick response.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You're welcome! Good luck.

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

Sign In or Register to comment.