![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | oublieduchaos |
Hi there!
extends KinematicBody2D
const flow = -1
const speed = 10
const maxspeed = 100
var motion = Vector2()
func _physics_process(delta):
if Input.is_action_just_pressed("down"):
motion.y += speed
motion.x += speed + flow
So that my code, and i can press the down button (already configurated in the project setting) but it doesn’t do anything… in fact any input button event isn’t working at all so i maybe misread something!
Thansk a lot
OublieduChaos
I don’t see anything wrong there, assuming you have the input configured correctly.
What happens if you add a few print statements to the code?
func _physics_process(delta):
print('inside physics_process')
if Input.is_action_just_pressed("down"):
print('inside input event')
motion.y += speed
motion.x += speed + flow
Which messages do you see when you run the code?
jgodfrey | 2022-08-04 20:48
Also, to be clear. That Input
code will only run once per each press of the down
binding.
jgodfrey | 2022-08-04 20:59
Also, assuming you see the first message (inside physics_process
), you’ll probably want to remove it from the code as it’ll spam your console and make it hard to see the other message.
jgodfrey | 2022-08-04 21:00
So after erasing the 'inside physics_process'
I see every time an input is made a 'inside input event'
So meaning the input work, i think i’m missing something to make the body move… but i’m more tired everynight and so blocking on this line isn’t a good thing to do, so waiting for your answers, and thanks, a lot!
oublieduchaos | 2022-08-05 11:49
You’re going to need to post more code to get any assistance with the movement problem. In the code you’ve shown so far, you’re setting the x
and y
components on a motion
variable, but you don’t show where/how that variable is used in the movement code.
jgodfrey | 2022-08-05 13:35