I've got a player ship (kinematic body) that's currently picking up collisions:
func _physics_process(delta):
var collision
for y in active_craft.get_slide_count():
collision = active_craft.get_slide_collision(y)
print(active_craft.name, " collided with: ", collision.collider.name)
And an explosion with an Area on the same collision layer to the ship's mask.
func _on_Shell_splash_down(position):
var player_id = get_child(0).name
if not get_child(0).has_node(str(player_id) + "Explosion"):
var explosion = explosion_scene.instance()
var area = Area.new()
var col_shape = CollisionShape.new()
var sphere = SphereShape.new()
sphere.radius = 50
col_shape.shape = sphere
area.set_collision_layer_bit (19, true)
area.add_child(col_shape)
explosion.name = player_id + str("Explosion")
area.name = player_id + str("Area")
explosion.global_transform.origin = position
get_child(0).add_child(explosion)
explosion.add_child(area)
explosion.get_node("Particles").restart()
I want the explosion to trigger the collision in the KB in order to deal damage. Can Area not be used with KinematicBody in this way or is there an error in my implementation?
Thanks in advance!
EDIT: It's clear the collision on move and slide only picks up bodies. My instinct was to handle damage on the KB but the code is clearly set up to have the bomb / shell / bullet handle that. Closing this.