Collision events between different body types

Feb 7, 2011 at 3:46 PM
Edited Feb 7, 2011 at 3:48 PM

Hi,

I have searched the forums before posting something, but couldn't find anything satisfactory.  Please if the same question have been asked, please redirect to discussion please.

So like everyone else we are trying to build a game using Farseer to simulate our 2d physics requirements.  In order to achieve what we want to achieve, we have objects that utilize all three body types.

Static is used for all the non-moving obstacles, dynamic for all the objects that is not controlled by the user and then a kinematic body type which is controlled by the user. (This I got as per suggestion reading through other discussions).

No, my problem is that I only get collision events between Dynamic and Static, Dynamic and Kinematic, but not Kinematic and Static.  Is there any flags I need to set for this to occur ? I have already checked the Collision categories but everything seems the same. Am I missing something ?

Thank you very much,

Jaco

 

Coordinator
Feb 7, 2011 at 6:26 PM
Edited Feb 8, 2011 at 5:46 PM

Both static and kinematic bodies are infinite in mass and it is not well defined what happens when an immovable object hits an irresistible force.

I understand your requirement, but the engine is designed to not collide static and kinematic bodies.

Feb 8, 2011 at 5:19 AM
Edited Feb 8, 2011 at 5:40 AM

The reason is that the 'walls' and obstacles which don't move, are flagged as static, but the 'thing' that the player moves can't be affected by forces as its 'suspended' in mid air, while all the other objects that are in the world are dyamic.  Think of the player controlled entity as a the paddle in arkanoid.   The position has to be updated manually but still affect other bodies or get collision info.  Does that make sense ?

EDIT:

So, if its possible, the engine doesn't have to handle the collision, I just want the 'hit test' to fire the collision event.

Coordinator
Feb 8, 2011 at 5:51 PM
Edited Feb 8, 2011 at 5:52 PM

There are a lot of way to control the character using the mouse. It all really depends on your game and how you would like it to "feel".

I've seen a lot of solutions:

1. Using dynamic bodies, setting linear velocity to 0 on each update.
2. Using the contact information to separate the two elements manually
3. Using forces
4. Stiff mouse joint
5. Small distance joint (with fixed rotation = true on the body)

It is really up to you to create the movement of the character. There is no "correct" (the physics engine way would be to use forces/impulses) way of doing it.

Feb 9, 2011 at 7:51 AM
Edited Feb 16, 2011 at 9:19 AM

Hi,

Thanks for answering all my questions so far. 

I 100% understand that its up to each individual requiremets to utilize the engine in a way to fit what they are trying to achieve. 

A perfect solution would be for me to use the physics engine to simulate the movement, but I couldn't.  The reason being that first, we have Gravity set in the game, this is needed so that the balls being generated continually falls down and bounce as they should. The player's 'cup' object, needs to be suspended in mid air, because the player needs to move the cup to catch the balls.  No, I tried IgnoreGravity = true, which suspends the cup, but if any ball falls on it, it can't be kept in place, which makes sense. I tried applying LinearDampening, but the problem is, applying forces on the object, even HUGE values, does not affect the cup to get the desired smooth movement that we want.

Based on the information I just supplied, could you be able to suggest a better way to get the desired behaviour?

EDIT:

Don't know if anyone would be able to use this, but I solved it using the Weld joint. 

So what I do is I build up my player object with Dynamic body types, weld each component together, then create a static body and weld it to the bottom of the composite object, setting its collisiongroup to none, no I can manually set the static body's position and receive collision events from the other parts.

Big thanks to Genbox for all his replies.