How to de-spawn or remove a spawned actor
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
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
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.
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
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
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
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
Ahhh it works now, thank you so much Tatiang!
You're welcome!
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User