This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

plz can anyone help my this is the script

extends KinematicBody2D

var motion = Vector2()
var speed = 150
var gravity = 100
var dir = -1

func _ready():
pass

func process(delta):
motion = move
and_slide(motion,Vector2.UP)
pass

func physicsprocess(delta):
motion.x = speed * dir
if isonwall():
dir *= -1
$Sprite.flip_h = !$Sprite.flip_h
if is_on_floor() == false:
motion.y += gravity
pass

the problem here the enemy gliching in the wall and go left and right in the same place
What should I do ?

in Engine by (14 points)

One suggestion: move the code motion = move_and_slide(motion,Vector2.UP) to the _physics_update() function, since that's where the collision calculations are performed.

thank you very much but i change the code

motion = move_and_slide(motion,Vector2.UP)

to

_physics_update()

but it say error Maybe I don't understand what you mean

error(14,1): the method "physicsupdate" isnt declared in the current class

1 Answer

0 votes

physicsupdate():
motion = moveandslide(motion,Vector2.UP)

by (59 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.