How to de-spawn or remove a spawned actor

Spacemarin37Spacemarin37 Member Posts: 5
edited April 2015 in Working with GS (PC)

Hey guys,

I'm trying to make a spin the wheel game, where if the arrow lands on a portion of the wheel (main actor), it will display some text (the spawned actor). I've got the wheel working, the text's displays like it's supposed to but the problem is, if I spin the wheel again, the old text stays on and is overlapped by the new text. Is there a way where the text only spawns if the arrow lands on, say, section A of the wheel, and if the arrow is no longer pointing section A, the text is removed?

Right now, I've made a rule for each section of the wheel like this;

When All of the following are happening
actor overlaps or collides with: actor of type (Actor)
if self.rotation >= 202.6
if self.rotation <= 225
Do
Spawn actor: (Actor) place: front of layer
in the direction: 0 relative to scene
from position 242, 160 relative to scene

Thanks in advance

Comments

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

    Destroy the spawned actor with a Destroy Actor behavior whenever you start a new spin.

    Another option is to consider NOT spawning an actor and instead just constraining an attribute to a table cell based on the rotation. So you'd display row 1 if the rotation is a certain value and row 2 if a certain value, etc. This is easiest if your wheel sections are uniform (e.g. every 30°) because then you can use a mathematical expression to determine the table row.

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

  • Spacemarin37Spacemarin37 Member Posts: 5

    Could you explain more on how I could destroy the spawned actor whenever I start a new spin please?

    I don't really understand the latter suggestion.

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

    How are you determining when to start a new spin? What is the rule condition that makes that happen?

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

  • Spacemarin37Spacemarin37 Member Posts: 5
    edited April 2015

    The players spin the wheel (by swipe). When the wheel spins, it'll land on a section of a wheel, when that happens some text (actor) will appear next to it. Once they read it, they are free to spin the wheel again

  • Spacemarin37Spacemarin37 Member Posts: 5

    I've placed the rules on the wheel, swipe controls and then 16 rules for when the arrow points at each section, each section will spawn a different actor.

    I followed this to create the sections if it helps
    https://forums.gamesalad.com/discussion/61177/how-to-make-1-actor-recognize-another-actor

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

    In the swipe detection actor (perhaps that's your wheel actor):

    If [a swipe is detected]
         change attribute game.destroyOldActor (boolean) to true
         Timer after 0.1 seconds (with run to completion checked)
              change attribute game.destroyOldActor to false
              Spawn Actor [display actor]

    In the spawned actor:

    If attribute game.destroyOldActor is true
         Destroy Actor

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

  • Spacemarin37Spacemarin37 Member Posts: 5

    Ahhh it works now, thank you so much Tatiang!

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

    You're welcome!

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

Sign In or Register to comment.