0 votes

Hi
I have a KinematicBody2D player node in which I want to check 'if the player is not colliding with anything, run code' but I can't figure out how. I am new to Godot so detailed explanations will really help me out. Thanks in advance

Godot version 3.4.2
in Engine by (14 points)

1 Answer

0 votes

I havent used this myself but if you use the code

if not is_colliding():
    do your code here

this should work. You could put this in

func _process(delta):

which will automatically run each frame so you will always be checking. This will take up processing time each frame though so I dont know if this will slow down the game at all.

by (2,001 points)

Sorry I should also have mentioned this will only work in a script on a node with the is_colliding(): function built in so for instance have raycasts in your player scene which can detect contact.

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.