Destroying an actor once it leave the screen
Kamazar
Member Posts: 287
Ok, so I still feel a little lost with the attributes, true and false stuff, it just all feels messy and disorganized in my mind. All I want to do is basically have an object destroyed when it's X-location goes over 480 or under 0 and it's Y-location over 320 or under 0. Basically, when it leaves the screen. I have some idea on how to do it, but I'd like a brief walkthrough. Thx
Comments
BUT!!!
You're very much on the right track. In your actor you want destroyed, just put a rule that says 'when an attribute changes' self position x is greater than 480
Do that for the rest of the screen limits and make sure the rule is set to 'any'.
Then add the 'destroy actor' behaviour.
That should do it.
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
So it basically entails using the x and y axis
In my game, I have enemies flying down from the top of the screen, so I created a rule that once the enemies hit the ground, they are destroyed, so they don't get cycled through over and over (top of screen again)
(under the actor you want to have destroyed)
Create Rule: When any conditions are valid:
When self position Y is less than 0
Destroy this actor
You can play around with these numbers depending on where on the screen you want the actor destroyed, or to not reappear
So if they're spawning from the right of the screen and walking from right to left
You'd place the same rule only
If self position X is less than zero, destroy this actor
Hope this helps!
( I also use the constrain attribute to keep actors from spawning in certain areas in the scene, let me know if you need help with that, those go hand in hand)
Also, the constrain attribute helped me to keep enemies within the boundaries of the screen, and not on the borders
But invisible walls are great too! I plan to use them in future games, it just didn't work in the current one
Finally got the basic gameplay down! Now it's time to work on scoring, lives, pausing, then last of all, graphics.