added sound pack and played with rocket launcher animations
This commit is contained in:
@@ -37,16 +37,24 @@ func _on_body_shape_entered(body_rid, body, body_shape_index, local_shape_index)
|
||||
func explode():
|
||||
#get all collision objects that can be moved
|
||||
var moveable_rigidbodies = blast_radius_area.get_overlapping_bodies()
|
||||
|
||||
#for each object determine vector from center of blast radius
|
||||
#apply linear velocity power as the inverse % of distance towards the edge (bonus points if using curve texture)
|
||||
#break breakable objects
|
||||
for body in moveable_rigidbodies:
|
||||
|
||||
#calculate blast power and direction
|
||||
var blast_direction = (body.global_position - blast_radius_area.global_position).normalized()
|
||||
var blast_amount = 1 - ((body.global_position - blast_radius_area.global_position).length() / blast_radius)
|
||||
var blast_velocity = blast_direction * blast_power * blast_amount
|
||||
|
||||
#apply and/or damage
|
||||
if body.is_in_group("scene_rigidbody"):
|
||||
var blast_direction = (body.global_position - blast_radius_area.global_position).normalized()
|
||||
var blast_amount = 1 - ((body.global_position - blast_radius_area.global_position).length() / blast_radius)
|
||||
var blast_velocity = blast_direction * blast_power * blast_amount
|
||||
if body.is_in_group("breakable"):
|
||||
body.breaking(blast_velocity)
|
||||
else:
|
||||
body.linear_velocity += blast_velocity
|
||||
if body.is_in_group("player"):
|
||||
body.velocity += clamp(blast_velocity,Vector3(-7,-7,-7),Vector3(7,7,7))
|
||||
if body.is_in_group("npc") or body.is_in_group("enemy"):
|
||||
body.velocity += blast_velocity
|
||||
body.breaking(blast_velocity)
|
||||
|
||||
Reference in New Issue
Block a user