0 votes

I am working on a game in Godot as a practice, not for selling and I want to detect the collision between a kinematic body and a rigid body. So far so good, the player (kinematic body) can stand on the rigid body, but I don't have a getcolliingbodies function for kinematic body.
Here is the player code:

extends KinematicBody2D

export var viteza = 30
var animNod
var jumped = false

func _ready():
    animNod = get_node("AnimatedSprite")

func _fixed_process(delta):


    delta *= 10
    var misc = Vector2(0,1)

    if(Input.is_key_pressed(KEY_D) or Input.is_key_pressed(KEY_RIGHT)):
        misc[0] = 1

    if(Input.is_key_pressed(KEY_A) or Input.is_key_pressed(KEY_LEFT)):
        misc[0] = -1

    misc = misc * (delta * viteza)



    var newAnim = "idle"

    if(Input.is_key_pressed(KEY_D) or Input.is_key_pressed(KEY_RIGHT) or Input.is_key_pressed(KEY_A) or Input.is_key_pressed(KEY_LEFT)):
        newAnim = "mers"

    if((Input.is_key_pressed(KEY_SPACE) or Input.is_key_pressed(KEY_W)) and not jumped):
        jumped = true
        var hVector = Vector2(0, -1)
        var hSpeed = 2
        var jH = 50
        hVector = hVector * (delta * hSpeed)
        newAnim = "saritura"
        var height = get_pos()[1]
        while get_pos()[1] > height - jH:


How to detect collisions between them?

in Engine by (61 points)

1 Answer

+1 vote
Best answer

KinematicBody2D has a method called is_colliding. You can get the collider with get_collider.

by (699 points)
selected by
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 Frequently asked questions and 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 [email protected] with your username.