# Smooth Collisions Between Objects (Help)

0 favourites
• 11 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
• Mmm, Why they don't allow us anymore to replay or post if its two years old thread? that post was for some nice mechanics nothing old lol

I'm referring to this Post:

Anyway

Thanks R0J0hound for sharing, the third one works great!

I have been trying for a week to replicate the Physics (collisions and Movement) as I couldn't find the right balance for what I needed.

For the Movement I found one of your examples to use instead but I'm still looking for how to do the collisions using bullet without using the bullet bounce out of solids because it behaves strangely.

So I tried to integrate it with your example number three using bullet and it's nearly there but it fail many times if I add the extra object Balls

Do you know if it's possible to make a good solid collision without the physics?

Also will be great if it could count with the ( Linear Damping, Mas, Angular dump) exactly as the physics behaviour does.

Exactly like this:

here is an example that prepared and adjusted the settings.

As you can see when the ball collides with the other one, the impact stops the first one that collides and pushes the next ones as it takes into account ( Linear Damping & Mas) so it looks natural, and the same for all the balls that collide, plus also counting the Solid walls.

• I guess the issue is there is an infinite loop when two balls collide in your events.

Anyways here's a better approach.

When a ball hits a wall the ball is moved out in the closest direction from the wall and a bounce calculation is done with that direction.

In a similar fashion when two balls collide they are moved apart and a bounce calculation is done.

All balls are assumed to have the same mass and all the walls are not rotated.

In events i used 16 and 32. That's the radius of the balls and 2*radius.

Damping can be done by multiplying the velocity by 0.995 or something. Angular damping doesn't make sense unless we are doing angular velocity too.

If you want different masses or different levels of elasticity you can change up the bounce code with:

en.wikipedia.org/wiki/Collision_response

• Woow!!

"Rohjo" you are a lifesaver this is absolutely beautiful )))

I was almost gonna give up this mini-project that I wanted to finish quickly as it was getting too ridiculous complicated I haven't slept in a week and again you save me always in the critical moments.

I'm so glad that you are still around to give us all those cool stuff.

I'm just having a bit of issue trying to integrate it with the Bullet behaviour which is the one I choose for the Balls movements which you recommended in another thread by using this equation:

sqrt(-2*1000*-200)

And acceleration = -200

As I found it the simplest and I like the results better than the physics

The mechanic that I'm looking to do is like "8 ball Billar" like the second capx I posted above.

So you shoot a ball and if hits another ball the impact will make them move the distance depends on how hard was hit by the other ball until they stop, so I guess I will need to calculate starting from the speed of the first ball? and not sure how this can be done.

Also I'm not sure how to feed the results into the bullet,

I tried:

Set bullet Speed To : Self.Bullet.Speed + distance( Self.X, Self.Y, self.X+self.vx*dt,self.y+self.vy*dt)

Set Bullet Angle of Motion To = a

And I placed on the sub-events that are marked as "Bounce" and still didn't work I must be doing everything wrong.

But is not a must that I should use the bullet if this method works the same. As I see there is the dumping ready to use so that could be the same as bullet deceleration that's very clever.

Probably because I'm tired so I still don't see it clearly how I should approach this, I will sleep and I will try again when I wake up fresh.

This is what I tried so far

Thank you so much for your help I really appreciate it

• If you want to use the bullet behavior, the simplest solution would be to set vx,vy in an event above the events I gave, and then setting the bullet angleOfMotion and speed in an event after.

Vx = speed*cos(angleOfMotion)

Vy = speed*sin(angleOfMotion)

Speed = distance(0,0,vx,vy)

AngleOfMotion = angle(0,0,vx,vy)

The other equation you gave was for figuring out the initial speed to stop in a specified distance. From your description you don’t need that. You just need to slow it down.

Global number speed=0

Global number dir=0

For each ball

— set dir to angle(0,0,ball.vx,ball.vy)

— set speed to max(0, distance(0,0,ball.vx,ball.vy)-200*dt)

— ball: set vx to speed*cos(dir)

— ball: set vy to speed*sin(dir)

• Thanks a lot Rojoh

I changed the events to the one you described but I still can get the balls to move after another Ball collides with it

It looks like the "Impact Value to Push the other Balls" Which depends on the Force of impact is still not taking into account or I may be doing the events wrongly

Here is an example what I was trying do :

This is what I got so far:

Events:

• You're not setting the bullet speed and angle of motion after the events. The result is it just pushes the other balls aside.

Anyways here's a revision with damping. If you want to use the bullet behavior there are some comments of what to modify and where.

dropbox.com/s/0figv3qlg6wdtv0/collision_responce_2.capx

• Yeah, Awesome!! R0J0hound that's the one, Thank you so much for all your help and for your time ))) I learned a lot from all your examples, is so great.

I have just one last question how would I control the bouncing Strength against the (Wall or Balls) they are quite high at the moments, I tried to manipulate the (vx, vy) on the bounce events but it goes crazy also I tried to reduce the speed and acceleration see if it helps on the bouncing but the speed it becomes too slow. I had the same problem with the physics the speed is right but the bouncing is too soft so when they bounce they bounce quite strong.

Thanks for the notes that helped a lot as I wasn't sure I understood you right the first time that's why I did it wrong

• Haha I think I found it, I tweaked the final result on "relv" and seems to work Great!!

Finally, I can sleep on peace ))) Nice to see working nicely finally after that long, I really thought that it wasn't gonna be possible and that I will have to drop it and move on, you are genius.

Rojoh you are the best, sorry for all the trouble, I own you many coffees by now I hope one day you will take it from me.

Take care and have a good one!!

• I Wonder if the gravity event suppose to make any difference as I wanted to do some kind of curve effect to one of the balls after shooting and I thought that maybe I could use the Gravity event but doesn't matter what values I enter on gravity it doesn't seem have to any effect even putting Gravity = 10M.

At the moment I'm using the move method with Bullet if that makes any difference.

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• You set the variables from the bullet behavior right after so it nulls any changes you do before. Move the gravity action down to fix that.

It’s probably not what you’re after though. Curved motion for pool balls is caused by friction between the ball and the table as the ball spins around in 3D. The physics model as is doesn’t account for that.

• Hoh that was the problem I see

You are right is not the effect that I was hoping for

Thanks for the info

• 11 posts