I had this idea that when a bullet hits an object the bullet will create more bullets but the problem is that I want the bullets to get destroyed when they collide with objects and walls and when the bullet hits an object it doesn’t spawn, because I think the bullets that it spawns get absorbed by the object it collided with. I want the child bullets to collide with whatever the parent bullet collides with but like I said, when the parent bullet hits an object the child bullets it spawns get absorb by the object it collided with.
show me the code. I need more information
What about this add some invisible frame to that object for like 0.2 seconds
When the children bullets spawn it will collide but it’s fine because that object has invisible frame so it can continue going
In your collide event just add a line to check if
- Your bullet collides AND that object has NO i frame
→ set an i frame to that object then spawn more bullets
uhm, what do you mean by invisible frames?
Can’t show right now as I’m not currently home
But it’s just very simple, the parent bullet has the fire bullet behavior, and when the parent bullet hits an object it is then deleted and will fire off the child bullets
It is a state of an object to tell that this object can’t be hit anymore until it’s out of its invisible frames
Basically when you get hurt then you appear with a flash blink effect
white → normal color → white → normal color
or color faded → normal color → color faded → normal color
So apply the i frames with your target object
First you fire a bullet
Then the bullet hits a target
Then the actions happen:
- Make the target be in i frames for x seconds (you don’t have to visually change it just change it’s state or boolean and after an amount of time change it back)
- Spawn more bullets everything is fine
Conclusion: to avoid instantly deleting your bullet you need to let them live for a while before checking the collisions.
Gdevelop read events from top to bottom
So if you would make
Condition
Bullet is in collision with SOMETHING
Action (ORDER HERE IS CRUCIAL)
1 - delete SOMETHING
2 - create child bullets
3 - delete parent bullet
You should be perfectly fine
Nice, this one actually worked thanks alot!