NEED BIG HELP with recycling bullets for enemy actor!
GLA
Member, PRO Posts: 60
Hi everybody! Can someone help me with this thing?
So in order to help me let me tell you what's all about.
I have an actor which is the player actor and the recycling bullets method works perfectly, but i want to implement a similar method to the enemy actors.
So i have one bullet for each enemy actor. This bullet is active when :
1. self.position.x = self.starting X
2. self.position.y = self.starting Y
3. bullet is in the camera area
and it will recycle when it touches an wall or its get outside the camera area.
also the starting X and Y for the bullet will be the same as the enemy actor's position x and y.
everything work perfectly by now but now comes the problem:
after i destroy the enemy i want the bullet not to recycle any more, i want to destroy it, so it can't be active any more.
By now the bullet is still active and it will shoot even after the enemy is destroyed.
So anybody can help me with that?
Any ideas?
So in order to help me let me tell you what's all about.
I have an actor which is the player actor and the recycling bullets method works perfectly, but i want to implement a similar method to the enemy actors.
So i have one bullet for each enemy actor. This bullet is active when :
1. self.position.x = self.starting X
2. self.position.y = self.starting Y
3. bullet is in the camera area
and it will recycle when it touches an wall or its get outside the camera area.
also the starting X and Y for the bullet will be the same as the enemy actor's position x and y.
everything work perfectly by now but now comes the problem:
after i destroy the enemy i want the bullet not to recycle any more, i want to destroy it, so it can't be active any more.
By now the bullet is still active and it will shoot even after the enemy is destroyed.
So anybody can help me with that?
Any ideas?
Comments
Hi @GLA the recycling method was a really good workaround when there was a memory-hogging problem with GSC (deleted/destroyed stuff not clearing out of RAM) but that's now long gone….
But if you still want to use the recycling method, you'll need a series of bullets that you can cycle through, to avoid reusing/repositioning a bullet that's already in use/hasn't been finished with.
Some sort of loop mechanism is useful here:
When Bullets<5 --- if you decide on 5 bullets, for instance, to prevent overlap
Change Attribute Bullets to Bullets+1
When Bullets=1
--move bullet 1 into position
When Bullets=2
--move bullet 2 into position
etc.,
When Bullets = 5
Change Attribute Bullets to 0
Of course, to avoid this unnecessary complication just use Spawn for your bullets and you won't have any overlap. Remember to put in a Destroy behaviour within your parameters and everything should work out fine.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps