Game Development Community

How does mass affect physics collision responses?

by Darius · in Torque Game Builder · 02/11/2009 (8:57 pm) · 6 replies

I'm working on a game where the player sets up soldiers on top of buildings and has them shoot at zombies that run past in the streets. But when the bullets collide with the zombies, it knocks the zombies around a lot more than I would like.

Currently the zombies are sending physics, and sending and receiving collisions. The bullets are only sending collisions. I would turn off the physics for the zombies, but I need them to collide with the buildings. I figured the best solution would be to make the zombies to massive, and the bullets so light that the zombies wouldn't be affected by the bullets. So I set the zombie's mass to 10800 and the bullets mass to .0001, but still the zombies bounce around when hit by the bullets.

Anyone have any suggestions on how to overcome this? Thanks.

#1
02/12/2009 (2:57 am)
Two-way collision options can be confusing but you have to think about the direction of collisions for any one action.

In the case of your zombies, you want them to collide with buildings. Well if the buildings are stationary but your zombies are moving then you only need to use send collision for the zombie for that action to occur. Presumably you also want a collision response when you get a send collision (zombie hits a wall) so you turn on send physics (note this doesn't send anything to anyone).

If your bullets are sending collisions so that you hit zombies then the zombies require receive collision enabled.

Now, finally, you don't want a collision response when the zombie receives a collision so you disable receive physics on the zombie.

In this way, a zombie sends collisions (actively checks for collisions when it moves) and has send physics enabled so that when it hits anything (due to its send collision being active), it responds with the selected response. When a bullet is fired, it sends collisions (actively checks for collisions when it moves) and it will hit a zombie because the zombie also has receive collisions on (will accept collisions being sent from another object). However, the zombie won't react with a collision response when a collision is received because the receive physics is disabled.

You can find more detail about this in a document here. Although I don't recommend it, you can skip to page 23 where I describe the send/receive idea in more detail.

Hope this helps,

Melv.
#2
02/12/2009 (8:26 am)
... to answer your mass question:

Mass doesn't have anything to do directly with a collision response. What it does relate to is how a force, applied to an object, affects its momentum.

For instance, if I applied a force of 10 to an object of mass 1 (ignoring the units here to keep things simple) then the object will effectively have an instant acceleration of 10 (world-units). If however the object had a mass of 2 then the effect of a force of 10 would be to give it an instance acceleration of 5 e.g. half.

In other words, the actual change in an object is inversely proportional to its mass. If the mass is halved, the resultant change would be twice.

A large mass object needs more force to move it.

Some of the functions allow you to ignore this by selecting "gravitic". This essentially ignores the objects mass and will have the same effect on every object irrelevant of mass.

Also, be careful with how this is applied. If you change the velocity of an object using "SetLinearVelocity" then mass is irrelevant. You've already bypassed the calculation and applied the velocity directly. The mass is only relevant when you applied a force, not set the velocity directly.

My previous post though seems a more direct answer to your problem.

Melv.
#3
02/12/2009 (8:54 am)
Those are both very helpful, thank you.
#4
02/12/2009 (8:57 am)
You're most welcome.

Melv.
#5
06/05/2009 (10:08 pm)
I'm having this same issue with a GTA style game.

When the player shoots a car, the car is greatly impacted and is moved across the screen.

I still want the car to receive physics for when it impacts with other cars but I don't want the bullet to move the car at all.

On the bullet I have the following set:
Send Collision
Receive Collision
Callback

On the car I have the following set:
Send Collision
Receive Collision
Send Physics
Receive Physics
Callback

Any ideas on how to make this work?
I already tried increasing the cars mass to 1000 to stop the smaller massed bullets from being able to move it but this failed to work.
#6
06/06/2009 (3:42 pm)
I found a quick fix for this.

I just create my own onCollision function and when a bullet hits the car I just stop the bullet's linear velocity and the car never moves.

You wouldn't think this would work but it does so I will just accept it and move on.