Weird behavior with bullet bouncing on solid

Get help using Construct 2

Post » Fri Aug 28, 2015 10:43 am

Hi !

http://canapin.com/construct/canagolf/01/ (mouse + click)

Bullet, angle, speed, bounce on a solid. That's pretty straightforward.

However, the bullet behaves strangely when it bounces in inner angles.
The ball sometimes seems to "jump" or teleport for a short distance in these cases.

Give a couple of tries here for example :
Image

It also happens on the four inner angles of each layout angle but it's harder to see.

Here are my events :
Image

And my capx : http://canapin.com/construct/canagolf/0 ... lf-02.capx

Any idea ?

edit : I tried with time scale to 0.2 and I can clearly see the ball teleport for a short distance in some case.
I need a precise behavior… :(

Should I switch to physics behavior in order to have better collisions ?
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Fri Aug 28, 2015 10:53 pm

The teleportation is due to the method C2 resolves the collision. You can use the two ways from the custom movement behavior's push our actions.
One is "push out nearest" which searches in a spiral like path around the object until a free spot is found. It works pretty well most of the time but in tight spaces like you have it can find a spot which isn't the nearest.

Another is the object moves backward until it's no longer overlapping. That works well except after the bounce. The issue is the backward motion is in steps and after a bounce the backward step could be too much so instead of stepping back to the starting position it could pass it back into a solid so it effectively could tunnel out.

The physics behavior is a simple way to have better collision resolution in that case. Or you can also do it all manually to have full control and in many cases have better results.

I'll see if I can wip up an example. A simple idea that strikes my fancy currently would be to do the push backward idea except keep it from pushing back further than the old position.
B
94
S
33
G
118
Posts: 5,396
Reputation: 75,853

Post » Sat Aug 29, 2015 12:14 am

Here's an example:
https://www.dropbox.com/s/eftq33ve74rul ... .capx?dl=0

It's actually three parts. The first is to move the ball. The second is to move the ball backwards out of the walls. The third is to calculate the normal from the ball to the walls so we can calculate a bounce. It's an approximation that may or may not be good enough.
Last edited by R0J0hound on Mon Apr 03, 2017 9:08 pm, edited 1 time in total.
B
94
S
33
G
118
Posts: 5,396
Reputation: 75,853

Post » Sat Aug 29, 2015 9:18 pm

Thank you very much !
I chose the physics behavior, easier to use. :)
B
12
S
7
G
7
Posts: 450
Reputation: 4,276


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 25 guests