How do I Detect When my Bullet has Bounced?

Get help using Construct 2

Post » Wed Jun 22, 2016 3:20 pm

I have a bullet which bounces off solids. When it bounces, I want it to decrease in speed, and generate a particle effect. How can I detect a bounce, in order to do this without performing a bajillion 'on collision with' conditions?

Edit: Other factors control the angle of the bullet - so detecting an angle change isn't accurate enough unfortunately :(
Last edited by mrtumbles on Wed Jun 22, 2016 4:18 pm, edited 1 time in total.
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 242
Reputation: 2,306

Post » Wed Jun 22, 2016 4:11 pm

If all else fails pin an invisible circle sprite to each bullet, make it just a little wider than bullet sprite and use an on-overlapping with anything condition. When it detects an overlap or collision (if you choose) then have it play/generate an invisible particle player set to play then delete and to act on the "closest" bullet instance to change speed.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
66
S
17
G
8
Posts: 637
Reputation: 9,370

Post » Wed Jun 22, 2016 4:17 pm

Would that not have the same effect as doing the collision checks on the bullet itself?
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 242
Reputation: 2,306

Post » Thu Jun 23, 2016 7:39 pm

My bad I misunderstood the problem. I saw "bounces off solids" and assumed it was a problem detecting the collisions on the bullet instance due to physics behaviors.
Short of putting everything your bullet could "bounce" off of into a family... I got nothing.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
66
S
17
G
8
Posts: 637
Reputation: 9,370

Post » Thu Jun 23, 2016 8:24 pm

Any particular reason why you don't want to use collisions on the bullet? If you have bouncing and solids enabled, those collisions will be calculated regardless, in case you're worried about performance, so you might as well utilize them for your effects.

Here is a past example I made for someone else that may be relevant, but it does use collision conditions - https://www.dropbox.com/s/6cliwidu8f51p ... .capx?dl=0
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Thu Jun 23, 2016 11:06 pm

Because the events might end up getting complex in the future as I add more solid objects, and not all objects carrying the solid property have this enabled.

Construct classic had this functionality OOTB - you could select the 'Solid' attribute in place on the selected object in the 'on collision with...' dialog - hence my hope there is some way of simply checking for collision with a solid.
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 242
Reputation: 2,306

Post » Fri Jun 24, 2016 12:00 am

Ah I understand. Then as previously mentioned, I think putting the relevant objects into a family (then check on collision with family) would be my suggestion as well.
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Fri Jun 24, 2016 8:41 am

Grah.

Another more elegant suggestion from reddit: compound the angle changes made in a tick to a single variable without passing them to the bullet, store it for the next tick along with the bullet angle, then check the bullet's previous angle against its current angle, offsetting for the previous tick's angle-adjustment - if there's a difference it should mean the bullet a bounced. Out of frustration I've moved to another part of the game to work on that, but when I return to collisions I'll try both implementations I think.
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 242
Reputation: 2,306

Post » Fri Jun 24, 2016 9:51 am

How many bullets will be bouncing ?
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Fri Jun 24, 2016 4:35 pm

Just the 1!
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 242
Reputation: 2,306

Next

Return to How do I....?

Who is online

Users browsing this forum: AekiroStudio, Lancifer, nahima and 17 guests