using Physics2DServer to simulate an explosion

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By steelxtreme

HI all, I’m trying to simulate an explosion (2D) and for that i’m using Physics2DServer directly, so far I got:

func _input(event):
if event is InputEventMouseButton and not event.is_pressed():
print("Mouse Click/Unclick at: ", event.position)
var circleShape = Physics2DServer.circle_shape_create()
var space_state = get_world_2d().direct_space_state

var params =

What i want is to apply forces or impulses at specific position. I have worked with unity3d for some years ago and Physx use Rigidbody.AddExplosionForce as far I remember and i want to replicate something similar. Thx

:bust_in_silhouette: Reply From: MarkProDev

I believe you’ll want to find a way to use apply_impulse assuming that your objects derive from RigidBody2D…

thanks, that’s what I’m trying to do but spacestate.intersectshape(params) returns an empty array, based in the shapes intersected i’ll apply impulse or force

steelxtreme | 2018-11-08 21:25