I’ve been using the game engine for some physic simulation and as well used the logic editor a bit, too. Now, my question is, how can I add some kind of constraint to a logic brick? Like if I’m using a colission brick, but only want to activate a condition if the strenght of the collission is larger than a certain value? Are there like ‘Object properties’ that could be used for such a thing? What I want to achieve with this is that if a rigid body collides with a cell fractured object only some parts are regaining their physics; the parts where the force was at some maximum. So, yeah.
If I understand, you want to have a pre-fractured object get chipped away by collisions.
Give each object a health property. Just give it to one fragment, select all (CTRL+A) and goto objects >> game >> add property at the bottom of the 3d view. Now use a near sensor and a collision sensor. On collision turn the object’s velocity into damage and add it to a property. Get the list of fragments that the near sensor hit and run through the list of objects. reduce the health of each object in the list and minus the damage property by 1. If the object’s health is 0 or less, apply physics.
Here is the pseudocode
cont = bge.logic.getCurrentController()
own = cont.owner
collision = cont.sensors["collision"]
near = cont.sensors["near"]
if collision == True:
for i in near.hitobjectlist:
if own.damage > 0:
i["health"] -= 1
own.damage -= 1
if i.["health"] <= 0:
A side note - there is Bullet code that enables this - getPhysicsImpulse or something along those lines, but it was never fully implemented.
It wouldn’t be hard to get. You could get the relative velocity of the object that hit it, and from there it’s momentum by multiplying by mass. That would give you an indication of ‘how hard it hit.’
But with logic, there’s no way I can see.
You can get the impact of a moving object. See Collision.
It measures the speed difference before and after impact. This makes it a bit hard to use.
Unfortunately there is currently no way to measure the force of a blocked object.
Maybe this can be an enhancement? Something like a pressure sensor?