Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Get contact force

Author
Message
monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 9th Apr 2014 19:14
Hi All,

I was just wondering if there is an easy way to get the contact force between two bodies. In particular I am wanting to check if my character is being squished between two objects, like a giant hammer coming down on top of them?

I can't just check for the contact between the hammer and the character because the player can/could jump on top of it, jump up and hit it when it's going back up etc..

This would also be useful for breakable objects/joints in the world, I could check if an object has collided with another with enough force, then manually remove the joint/body if it has.

Thanks in advance.

All programmers are playwrights and all computers are lousy actors.
Paronamixxe
AGK Bronze Backer
12
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 9th Apr 2014 19:52
Not too sure if it is possible to do it in that way...

Although, you could just create a non-textured sprite and place it "under" the hammer head. All you would have to do then is check for a collision with this "kill zone". A little primitive, but hey!

Hope this helps!

nope.

Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 9th Apr 2014 22:37 Edited at: 9th Apr 2014 22:40
i believe u search for the momentum transfer.
its a formula with mass and velocity.

then acceleration result in force.

force = mass * acceleration
F = m * a

if you can not move between 2 objects its friction.

GetSpriteContactSpriteID2 ( )
GetSpriteContactWorldX ( )
GetSpriteContactWorldY ( )
GetSpriteFirstContact ( iSprite1 )
GetSpriteNextContact ( )

GetPhysicsCollision ( iSprite1, iSprite2 )
GetPhysicsCollisionWorldX ( )
GetPhysicsCollisionWorldY ( )
GetPhysicsCollisionX ( )
GetPhysicsCollisionY ( )

GetSpritePhysicsVelocityX ( iSpriteIndex )
GetSpritePhysicsVelocityY ( iSpriteIndex )

GetSpritePhysicsMass ( iSpriteIndex )
SetSpritePhysicsMass ( iSpriteIndex, mass )

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 9th Apr 2014 23:26
Quote: "
Although, you could just create a non-textured sprite and place it "under" the hammer head. All you would have to do then is check for a collision with this "kill zone". A little primitive, but hey! "


I think I could hack away to get this to work, I could have a two kill zones (hammer head and strike point) and if the character is in contact with both then it's a hit.


Quote: "i believe u search for the momentum transfer.
its a formula with mass and velocity.

then acceleration result in force.

force = mass * acceleration
F = m * a"


That would work for non-driven free bodies, but for something like a light object that is slow moving but exerts a great force like a crusher this would require some other calculations based on the motor force. Although, I would know the force for these cases. So maybe I could use a mixture of these methods, good idea!

Thanks guys, you've given me a new way of looking at the problem. Much appreciated

All programmers are playwrights and all computers are lousy actors.
Paronamixxe
AGK Bronze Backer
12
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 9th Apr 2014 23:29
Anytime

cheers

monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 23rd Apr 2014 21:43
Sorry for bumping, I've just found out that Box2D has this functionality built in. You can get the collision force and friction from the post collision event.

TGC: this would be a great feature to add.

All programmers are playwrights and all computers are lousy actors.

Login to post a reply

Server time is: 2024-03-29 05:55:33
Your offset time is: 2024-03-29 05:55:33