Puck collision

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
ChrisN
Posts: 4
Joined: Fri Jun 13, 2008 7:48 am

Puck collision

Post by ChrisN »

I'm trying to get realistic puck physics going, any idees on what settings that should be used.. Also is there a center of mass attribute that you can access?

cheers
/ Chris
User avatar
Zukarakox
Not a Site Admin
Posts: 426
Joined: Mon Jul 10, 2006 4:28 am

Re: Puck collision

Post by Zukarakox »

Centerposition is the center of mass, you can't change it.

For the puck set the friction of the puck and the ice on low, have bounciness of both at 0 and maybe give negative bounciness to the walls (pucks seem to hug walls in hockey), not sure if negative bounciness is allowed.

Friction and bounciness both go up to 1, so I'd say friction both at -1 and bounciness at 0, -0.5 for walls, but thats just random approximations :P

You'll probably want like .015 angle damping for the puck -- friction doesnt deal with angular things.
i has multiple toes
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Puck collision

Post by Norbo »

I can't remember off the top of my head if I protect against negative bounciness and friction, but regardless, I recommend against it- strange things will happen :)

Friction will also slow down the puck's angular velocity as expected.


I do have a concern though; it is possible that where triangles and objects meet (assuming your playing field isn't one large continuous block), the puck will jump. v0.5's collision detection system causes this when an object is moving over a transition between two other entities and a new, different normal is detected for the new supporting entity. I may be able to iron this out in v0.6.0's system as it is essentially a full rewrite of detection. Until then, if you encounter this behavior, you may have to work around it by simply using a large base entity for the playing field (hopefully the sizes play well enough together that you don't encounter the problems I described in response to your earlier post) or by possibly even making your puck's physical shape a sphere, which would probably act a bit better when moving over transitions. Obviously this would pose some problems for simulating the rotation of the puck in a realistic fashion.

I might be able to work in a center of mass property separate from the geometric center in v0.6.0 if time permits.
User avatar
Zukarakox
Not a Site Admin
Posts: 426
Joined: Mon Jul 10, 2006 4:28 am

Re: Puck collision

Post by Zukarakox »

I think you protected against it now that I think about it.

But hmm... making the field 1 triangle (having its edges extend beyond the walls) would help. I noticed that in the early stages of golf when I was using a sphere the ball would default to following the lines between triangles because of said jumpy bug.

The problem with hockey is that the puck will need to 'glide'. Try applying a small impulse every update in the direction the puck is currently going to simulate slipperiness. For the collision model, I'd suggest a convexhull that is a cylinder but tapers off the tops and bottoms a bit. (Think of the bottom of a coke can) Heres an ASCII example :P (Dont mind the - spaces are not allowed to be spammed or something so I couldnt space :()

--_______________
/----------------------\
|-----------------------|
\_______________/



If you use a perfect cylinder, the edges would catch and the puck would pop up.

Thats all I have for now :P

Leave friction, angular damping and bounciness alone I guess -- but they are good for fine tuning your system for desired results once you have it going.
i has multiple toes
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Puck collision

Post by Norbo »

Instead of relying on a single triangle, you can use a single box. The better fit will help the collision detection work better. Also, in regards to the cylinder, only cylinders with a collision margin of 0 actually perfect cylinders- and 0-margin objects don't function very well. By giving your object a margin, you are spherically expanding it and smoothing out all the edges. This would be similar to the effect of creating a polyhedron with slanted edges at the bottom.

Regardless, with a bit of tuning, hopefully it will work out. The ideal solution would be that a playing field's large, single box entity works well in terms of collision detection. Just setting friction to a low value will be enough to have the puck sliding around nicely.
User avatar
Zukarakox
Not a Site Admin
Posts: 426
Joined: Mon Jul 10, 2006 4:28 am

Re: Puck collision

Post by Zukarakox »

Eeeeh -- stuff doesnt slide though, and pucks always seemed really slippery 2 me, but maybe Im just crazy.
i has multiple toes
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Puck collision

Post by Norbo »

I'm not sure what you mean by 'doesn't slide,' because if you turn down friction a bunch, things do tend to slide :o

Could it be that what you observed was due to the fact that the calculated friction of a collision pair is based on the average between the two entities' coefficients? If you had a 'ground' with a friction of 1 and a supposedly slidey box with a friction of 0, your applied friction would still be .5. I'll probably go ahead and add some options to the friction calculation in v0.6.0, such as use minimum friction, maximum friction, and some others.
User avatar
cosmixy
Posts: 225
Joined: Fri Jul 07, 2006 6:51 am

Re: Puck collision

Post by cosmixy »

You can bevel the corners of the puck. Basically the same thing, but a small bevel will make the edges look more natural too(not that looks are really of any concern right now =D)
User avatar
Zukarakox
Not a Site Admin
Posts: 426
Joined: Mon Jul 10, 2006 4:28 am

Re: Puck collision

Post by Zukarakox »

Why can't I ever be right :(
i has multiple toes
BabaJustin
Posts: 30
Joined: Mon Apr 25, 2011 6:07 pm

Re: Puck collision

Post by BabaJustin »

Was this ever resolved? I seem to be having very similar issues currently with Puck collision.

The puck is "bouncing" off of ledges instead of falling over. I tried beveling the edges of the puck and that improved it slightly, but the issue still persists. Everything works great if I use a sphere, but of course that isn't really an option.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Puck collision

Post by Norbo »

What version are you using? In v0.15.0+, triangle meshes have a special system designed to stop 'internal edge' bumps. If you're looking at a situation more like a cliff where two faces meet at a 90 degree angle or something, the convex may be hitting the backside of the cliff face. In that case, switch the Sidedness property of the mesh to something other than double sided (depending on the winding of the mesh).
BabaJustin
Posts: 30
Joined: Mon Apr 25, 2011 6:07 pm

Re: Puck collision

Post by BabaJustin »

Sweet, that fixed it thanks!
Post Reply