Jump to content
e_boulanger

Collisions not detected

Recommended Posts

I am developping a small Foosball game. I set the ball object physics to Rigid Body, Prop, and with a mass of 5.

 

The foosmen on a rod are attached to a pivot which controls their rotation. Each foosman physics is set to Rigid Body, Scene, Nav Obstacle = true.

 

When the ball is moving, it can react to the foosmen rotating. If the ball is stopped, the foosmen pass through the ball.

 

I suspect the way I set the physics is responsable for this. Does someone have a suggestion on how to set physics setting correctly so the foosmen can hit the ball when they are rotating.

 

Thanks.

E.

Share this post


Link to post

Try setting both to swept collision. Also load the foosball player into the Model Editor and pick a physics shape from the menu. See here for more details: http://www.leadwerks.com/werkspace/page/tutorials/_/models-and-animation-r8#section6

Note do not use Polymesh for either.

 

And unless you are going to build a navmesh, there is no reason to have the setting 'Nav Obstacle' as true. This probably has no effect either way if no navmesh, but just pointing out that option is meant for navigation.

Share this post


Link to post

also always try to use box shapes or sphere shapes (or convex hull) but I would not recommend a poly mesh physics shape.

They are very glitchy in my games, usually they dont have gravity enabled (when I use them)

Share this post


Link to post

Thanks everybody for replying. My first problem is my model itself. In the editor, I chose "Polymesh". Like MrShawkly said, they are problematic. I also read that the "Polymesh" react as if it has a mass of 0. Which is not good. So first thing I did, I change the "Polymesh" to the "ConvexHull".

 

Second, when I was rotating the foosmen, I rotated the object itself. Unfortunately, rotating an object by itself does not affect the physics of the game. So I had to change the waythe rotation was done. This was more complicated than I though. Before, everything was controlled through a pivot, to which all the foosmen on the same rod were attached to.

 

Now I have to individually assign a script to each foosmen, even if they are on the same rod. (I wish I could assign the script to the pivot, but it does not work) That script creates a joint.Hinge for each object. And in the UpdatePhysics function I had to use a script like this:

 

-- if X has changed

if currentMousePos.x ~= self.lastMousePos.x then

 

-- calculate difference

local diff = currentMousePos.x - self.lastMousePos.x

 

-- calculate new rotation

self.angle = self.angle + diff

 

-- set the angle and speed so that movement is quick

self.joint:SetMotorSpeed(diff * 60)

self.joint:SetAngle(self.angle)

self.joint:EnableMotor()

 

else

 

self.joint:DisableMotor()

 

end

 

Sometimes the rotation angle is wrong (I have to work on this), but now when a foosmen turn, it can come in contact with the ball.

 

Now I have to figure out a way to move the foosmen laterally as well. I am presently trying with a slider. But it gives me a bit of problem and I do not know if I can combine both the slider and hinge on the same object.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...