Adding bodies as detail objects

Official forum for the Chipmunk2D Physics Library.
Post Reply
OandO
Posts: 8
Joined: Tue Jun 04, 2013 10:48 am
Contact:

Adding bodies as detail objects

Post by OandO »

Something I've been having difficulty working out a solution to:

I have a level made almost entirely out of dynamic bodies, which collide with each other as normal, but I want to be able to add additional bodies as visual detail, for things like bullet casings and small pieces of debris. Their requirement is that they can collide with the rest of the world and respond by bouncing off etc. but not apply forces to any objects. Any suggestions to how I can accomplish this?
ben9000uk
Posts: 3
Joined: Wed May 15, 2013 5:00 pm
Contact:

Re: Adding bodies as detail objects

Post by ben9000uk »

Hello, so the easiest way i could think of to do this would be to just make the mass of the detail objects extremely small relative to the level bodies mass.
i.e 0.0001* smallest mass of a body
That should make any force by a collision pretty much negligibly small
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Adding bodies as detail objects

Post by slembcke »

So one thing that is easy to do is to implement it so that the detail objects only interact with static geometry like walls and such. This is terribly common in games.

The problem with wanting the detail objects to only have unidirectional collisions is that they will often get stuck between two regular objects. Setting the mass to be very low will give you similar problems. When you have a shell casing that is sitting on top of a crate and the player steps on the crate, weird things are going to happen. The end result that you are expecting for is probably very specific to what your game is.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
OandO
Posts: 8
Joined: Tue Jun 04, 2013 10:48 am
Contact:

Re: Adding bodies as detail objects

Post by OandO »

I think I'll try setting the masses to be tiny first. The game has a client/server structure, so if anything goes horribly wrong the server should be able to make up for it by sending over the correct positions pretty quickly. They're only going to be very short lived and simulated purely on the client, so it might be alright.

I did wonder taking a sort of double-buffered approach, where all the dynamic geometry is copied into another layer as static, and then simulate the tiny details in there, seems a little excessive though.
OandO
Posts: 8
Joined: Tue Jun 04, 2013 10:48 am
Contact:

Re: Adding bodies as detail objects

Post by OandO »

Just to follow up, setting tiny masses does what I wanted, the character ploughs through as though they weren't even there. Thank you!

http://www.youtube.com/watch?v=kqVMI0Cw2zQ
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests