Bullet double spawn problem
Been having a issue with my game for a while now, been procrastinating until now and i've a variety of different things but cant seem to fix it.
depending where the player clicks on the screen, the actor changes, e.g. i have
Player (facing right)
Player (facing center)
Player (facing down)
heres the problem, say the player last clicked round the bottom, so the current actor is Player (facing down), then when you click to the right, so Player (facing down) is destroyed and Player (facing right) is spawned...
TWO bullets fire on that first click, one from both actors, and the secondary unwanted bullet, i can tell is coming from the other weapon's position before it was destroyed. so basically everytime a player clicks an area on the screen that switches the actor, the first click fires two bullets.
ive tried making boolean attributes for each actor, making it so if "right touch area" is pressed, player right boolean = true, all other player booleans = false, when false, destroy actor, if true, obviously spawn actor.
i also tried doing this same thing but with a integer attribute, depending on the value, it spawns the appropriate actor, however this also didnt work.
it would appear whatever i try, its not destroying the actor quick enough, the bullet from the secondary actor thats destroyed, is somehow firing his bullet actor first before its destroyed.
any ideas to get past this?
to see what i mean further, heres the game http://gamesalad.com/game/42149 , click in different areas of the screen and you'll notice an occasional double-shot :S
depending where the player clicks on the screen, the actor changes, e.g. i have
Player (facing right)
Player (facing center)
Player (facing down)
heres the problem, say the player last clicked round the bottom, so the current actor is Player (facing down), then when you click to the right, so Player (facing down) is destroyed and Player (facing right) is spawned...
TWO bullets fire on that first click, one from both actors, and the secondary unwanted bullet, i can tell is coming from the other weapon's position before it was destroyed. so basically everytime a player clicks an area on the screen that switches the actor, the first click fires two bullets.
ive tried making boolean attributes for each actor, making it so if "right touch area" is pressed, player right boolean = true, all other player booleans = false, when false, destroy actor, if true, obviously spawn actor.
i also tried doing this same thing but with a integer attribute, depending on the value, it spawns the appropriate actor, however this also didnt work.
it would appear whatever i try, its not destroying the actor quick enough, the bullet from the secondary actor thats destroyed, is somehow firing his bullet actor first before its destroyed.
any ideas to get past this?
to see what i mean further, heres the game http://gamesalad.com/game/42149 , click in different areas of the screen and you'll notice an occasional double-shot :S
Comments
But could you not use 1 actor and change the anamation?
if i was to make just 1 actor, and change the image depending where you've clicked on the screen, how would i then be able to spawn the appropriate bullet spawn to accomodate where the player is facing, ill give you an example.
player clicked right side of the screen, bullet is spawned at the location of "player right"'s gun.
player clicks bottom of screen, bullet is spawned at the location of "player down"'s gun.
say i was to delete the additional 3 actors, and make it just change image, how much i make it spawn the bullet is the correct place?
i currently have it so each actor(playing facing different direction) has the bullet spawn coordinates ready, but if it was on 1 actor, how would i make 4 different bullet spawn rules, depending on where the player has clicked, it would have to be linked to what image its changed to from the "change image" rule, is that even possible?
I found the easiest (but probably not the best) way to do it was this:
I placed the player at the far left of the screen and had recyclable bullets shooting to the right. I then counted (literally!) how many bullets could be onscreen at once. This gave me the number of bullets I needed for recycling.
After making all the bullets that shot to the right, I made the same amount of bullets that shot to the left.
In effect, I have bullets for shooting left and bullets for shooting right.
What you need, I guess, is a variable called something like 'Facing'.
If the player's facing left, make 'Facing' = 1
If the player's facing right, make 'Facing' = 2
If the player's facing up, make 'Facing' = 3
If the player's facing down, make 'Facing' = 4
I think you already have something similar as your graphic is changing depending on where the player is facing.
There are also dual stick control stuff you can use - look in the creator under 'controls' to find an example that might help more.
I'm not sure that's any help. Hmmmm...
Good luck!
QS
Instead of rule to spawn you make the rule to change anamation in that rule you put the diffrent rules to spawn the bullets