Spawning multiple actors and then destroy when touches
se7rn@me
London / Cape Town Member Posts: 11
Hi all,
New to GS and new to building games. I've been looking for the answer on this forum and on youtube and could not find it. Hopefully one of you clever people out there can guide me into the right direction.
Question:
I have one actor which I spawn multiple times on a scene. I want to destroy these spawn actors when touches individually.
So far I can only get the one(dragged onto scene) destroyed. I cant seem to get it working. I'm obviously doing something wrong. Would appreciate the help on this one..
Regards
Sev
Comments
If you want to destroy the actor that is touched, use When Touch is Pressed --> Destroy Actor. If you want all spawned actors to be destroyed when one is touched, use When Touch is Pressed --> Change Attribute game.destroy (a custom boolean attribute) to true; When Attribute game.destroy is true --> Destroy Actor.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thank you for the prompt response.
I think i might not have explained it properly enough. I'm using youtube videos to learn and play around with various codes (ideas).
I have the when "touch is pressed ->> destroy actor" in the code. But it's only destroying the dragged actor on the scene and not the spawned actors. The actors are spawned based on a location table. If this is not useful i'll post the code on here tonight.
Again thanks for the reply. I appreciate it.
Sorry just to add. I'm using GSHelper (Spawn Actors without overlapping tutorials vidoe on youtube. But with the actors spawned based on the location table i want to individually destroy them when touched. I did add the code "Touch is pressed->>destroy actor" . But its not working. It only destroys the one actor.. Hope this makes better sense.
Thanks..
I think you'll need to do that because if you have a rule that ONLY has the condition When Touch is Pressed and is not inside of another rule and is set to destroy the actor, then whenever you click/tap on the actor, it will be destroyed. It doesn't matter if it's dragged, spawned, or anything else. So I'm guessing it's more complex than you've explained so far.
If you want to destroy multiple actors with a single touch, then you need some sort of identifying self attribute for those actors. They need to be able to check the value of an attribute and determine if they match or not.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thank you. I'll post code shortly. Much appreciated
I've attached the game file if it will help. Happy to just post screenshots if you like
You're missing the attachment. As a non-Pro member of the forums, you'll have to upload the project file (compress it as a .zip file first) to a file-sharing site and then post the download link here.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Sorry just realised it. thanks. I've dumped in Dropbox. Thanks again.
https://www.dropbox.com/sh/f5l7iwqsxponbpz/AADhvDUq4K7yj2ONLn81xYz6a?dl=0
Your Actor 1 doesn't have any rules!
When an actor is spawned, it uses the prototype rules for that actor. So if you want Actor 1 to be destroyed when clicked, you have to add that rule to that actor.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Also, I still have no idea whether you want all of the actors to be destroyed when you click one actor or just the actor that's clicked to be destroyed.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thank you so much.. It works now.. I've spent ages on it the last couple of days trying to figure it out. Even ordered a book online.
Yet again thank you very much.
Just the actor that is clicked to be destroyed.
You're welcome!
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User