Hello Tyler,
I really wanted to do that, but I thought my solution is
not really good. That's why I wrote "sufficient".
Ok, here it is.
Code in Blitzmax:
Function ApplyShockwave(position:tvec3, intensity:Float)
Local body:TBody
For Local gameobject:TGameObject = EachIn TGameObject.list
body = gameobject.body
If body <>NULL
' create a marker to make point of shockwave visible, replace with a pivot later '
Local marker:TMesh = CreateCylinder(8)
PositionEntity(marker, position)
Local mpos:TVec3 = EntityPosition(marker)
Local spos:TVec3 = EntityPosition(body)
Local distance:Float = EntityDistance(marker, body)
Local force:TVec3 = New TVec3
' substract position vecs and calculate force to apply'
force.x = (spos.x - mpos.x) / distance
force.y = (spos.y - mpos.y) / distance
force.z = (spos.z - mpos.z) / distance
If distance < 1 Then distance = 1 ' because of massive force if <1 '
force.x = force.x / distance * intensity
force.y = force.y / distance * intensity
force.z = force.z / distance * intensity
Local tforce:TVec3 = TFormVector(force, marker, Null) ' thanks Flexman! '
If EntityDistance(TEntity(body), marker) < 10 ' shcokwave only affects bodies in this distance
AddBodyForce(body, tforce)
EndIf
EndIf
Next
I am cycling through all my gameobjects because I couldn't figure out how to pass the two vec3s
to TAABB in Blitzmax at the moment.
Local t:TAABB = New TAABB.Create(Vec2(10, 10), Vec2(0, 0))
throws an error.