0 votes

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.

Godot version 3.2.2
in Engine by (202 points)
edited by

Does this implementation use signals? Are the signal connections properly setup? Is the Area checking for a body_entered() signal?

The onShellsplashdown method is receiving a signal but just for the explosion, regardless of whether there's a hit. This makes an Area as a child with a SphereShape which I was hoping would be picked up by the KB (and so register a hit) but no dice. Ideally I want the KB picking up the Area as a collision, rather than the other way round.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.