0 votes

Hi im really confused about why this code won't work properly. I used a similar code for side to side and it worked fine. I changed all the code that needed to be changed for it to move up and down but it still wont

extends KinematicBody2D

const LEFT = Vector2(-1, 0)
const GRAVITY = 0
const SPEED = 20

var motion = Vector2()
var up = Vector2(0, 1)
var down = Vector2(0, -1)
var direction = up
onready var animationPlayer = $AnimationPlayer

signal body_entered()
signal area_entered()

func _physics_process(delta):
    motion.x += GRAVITY
    motion.y = direction.y * SPEED
    motion = move_and_slide(LEFT, motion)
    animationPlayer.play("move")

    if is_on_wall():
        if direction == up:
            direction = down
        elif direction == down:
            direction = up
in Engine by (39 points)

1 Answer

0 votes

I'm not sure what you're attempting to do exactly, but I think this issue is that the isonwall() conditional statement is being run every single physics frame.
This essentially just rapidly switches between the two up and down directions and potentially could be leaving the object unmoving.

It would be helpful to know what effect you're trying to achieve though.

by (77 points)
edited by

Im not sure what you mean but the balloon is supposed to follow the mouse so that when you click on the mouse it appears where you clicked. The main problem is i cant get rid of the ballon following the mouse meaning i cant get it to drop. Sorry if its hard to understand

This is a bit inappropriate but since I understand you're on a time limit, do you mind if we move this to a messaging application? The comments are going far off topic from the question and it would be much faster and easier to communicate to you elsewhere.

would email be easier??

Do you have a Discord? If you do, you can share your tag and then hide the comment afterwards.

i dont unfortunately. I think it would be easier to just email because its not that slow

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 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 webmaster@godotengine.org with your username.