How do I fake physics collision redirection?

Get help using Construct 2

Post » Thu Mar 16, 2017 9:22 pm

I'm experimenting with some physics-like movement without the Physics Behavior. I'm sure it's been done on here before.. can't find any examples though.

I'm using basic Behaviors: CustomMovement and Bullet. I'm trying to redirect a 'block' based on speed/mass/angle of another block it collides with.

I need to somehow not add additional speed to the collision. I'm using a one-time Acceleration action like 'force'.. although that may be a bad idea? not sure. All I really care about is the CustomMovement one.. the Bullet one I might just destroy and therefore not care about that trajectory/speed etc..

I have to somehow take the speed of each object and it's angle to determine the force..since force cancellation would happen if angling directly toward each other - but also if going in slightly the same angle the only force would be the difference in speed. No idea how to do that.

Maybe I am oversimplifying this... maybe there's a physics behavior for a reason?

any help?

https://www.dropbox.com/s/z0v2rkibaipnq ... .capx?dl=0
Last edited by jobel on Fri Mar 17, 2017 1:58 am, edited 1 time in total.
B
88
S
29
G
14
Posts: 1,154
Reputation: 15,003

Post » Thu Mar 16, 2017 10:28 pm

Yup that is why physics commands exist becuase it does all those complicated adjustments for you automatically if the settings are correct.

You can do some pseudo-physics using the bullet behavior and it does have a gravity setting and velocity but determining impact speed is pretty complex.

What kind of game are you making?
Banned User
B
23
S
6
G
58
Posts: 1,229
Reputation: 34,540

Post » Thu Mar 16, 2017 10:33 pm

@lamar there's no gravity.. just angles and speed - would like to use mass if possible. I have it sort of working without using mass.

it does NOT work when the collision happen and the objects are going somewhat in the same direction - it just adds all this speed and does not look natural.

just experimenting for a top down space game..
Last edited by jobel on Thu Mar 16, 2017 10:34 pm, edited 1 time in total.
B
88
S
29
G
14
Posts: 1,154
Reputation: 15,003

Post » Thu Mar 16, 2017 10:33 pm

Image Image Image
B
29
S
11
G
27
Posts: 729
Reputation: 16,995

Post » Thu Mar 16, 2017 10:37 pm

@MPPlantOfficial yup already downloaded that old @Yann example.. gravity is not needed..just outerspace collisions. I couldn't figure a way to apply it.

I probably need to use sin and cos.. . just don't know really how...
B
88
S
29
G
14
Posts: 1,154
Reputation: 15,003

Post » Thu Mar 16, 2017 10:38 pm

jobel wrote:@lamar there's no gravity.. just angles and speed - would like to use mass if possible. I have it sort of working without using mass.

it does NOT work when the collision happen and the objects are going somewhat in the same direction - it just adds all this speed and does not look natural.

just experimenting for a top down space game..


I used the bullet behavior for one of my first pinball games and I was able to make it loook almost like real physics but like you said you could tell it was not natural physics and when two bullets collide you get strange effects that don't look natural.

You can use the Sine effect to some extent to get a more natural effect.
Banned User
B
23
S
6
G
58
Posts: 1,229
Reputation: 34,540

Post » Fri Mar 17, 2017 1:57 am

@R0J0hound any chance you could recommend something? just curious if this is even doable or if its more complicated than I'm making it.

I just want to figure out how to take into account the moving angles, speed and how that would effect the 'force' or one-off acceleration.
B
88
S
29
G
14
Posts: 1,154
Reputation: 15,003

Post » Fri Mar 17, 2017 2:08 am

I can live with setting the Moving angle of the GreenBlock after a collision to:
Code: Select all
angle(BlueBlock.X,BlueBlock.Y,GreenBlock.X,GreenBlock.Y) - 180

I just can't figure out how much to accelerate by.

I started with some arbitrary numbers and found some that work for most collisions. Then I tried to come up with a calculation that would fit those numbers. Most of it works well.

But it all fails in this one scenario where the BlueBlock is traveling right, and a GreenBlock is also traveling right but is going faster. When it catches up to the BlueBlock, the move angles are correct, except my calc fails miserably by adding way too much speed to the BlueBlock. My calculation doesn't account for trajectory.
B
88
S
29
G
14
Posts: 1,154
Reputation: 15,003

Post » Fri Mar 17, 2017 8:32 am

This link explains the math of a physics bounce:
https://gamedevelopment.tutsplus.com/tu ... medev-6331

I always found it hard to fake physics because it never looks right.
B
91
S
31
G
102
Posts: 5,232
Reputation: 67,250

Post » Fri Mar 17, 2017 3:05 pm

(VB−VA)⋅n+j∗(j∗nmassA+j∗nmassB)∗n+e∗(VB−VA)⋅n=0∴(1+e)((VB−VA)⋅n)+j∗(j∗nmassA+j∗nmassB)∗n=0∴j=−(1+e)((VB−VA)⋅n)1massA+1massB

yup that's what I figured.. :)
Last edited by jobel on Fri Mar 17, 2017 3:10 pm, edited 1 time in total.
B
88
S
29
G
14
Posts: 1,154
Reputation: 15,003

Next

Return to How do I....?

Who is online

Users browsing this forum: Magistross, mtnboy22, Rable and 8 guests