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")
set_fixed_process(true)
func _fixed_process(delta):
#MISCARE
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)
self.move(misc)
#ANIMATIE
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:
self.move(hVector)
animNod.play(newAnim)
How to detect collisions between them?