0 votes

So i am working on a game where i want the character to automatically run in right and when he collides with an enemy to do something, and i just cant seem to fix the collision thing.

the code:

extends KinematicBody2D

var velocity = Vector2(150,0)
var speed = 1555
func ready():
print(speed)
func _physics
process(delta):
var collide = moveandcollide(velocity* delta)
if collide:
print(speed)

i tried this but nothing gets printed, the player character is a kinematicbody2d and the enemy is also a kinematicbody2d, i tried with a staticbody2d too and isnt working.Thats the only script i have and its attached to the kinematicbody2d, im new into coding so i would be gratefull if anyone could help me and explain this to me

Godot version 3.4.2stable
in Engine by (15 points)

1 Answer

0 votes

Use

is_on_floor
is_on_wall
is_on_ceiling

if $KinematicBody2D.is_on_wall():
    print("lllllll")
by (755 points)
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.