(The content may be awkward because I use a translator.)
Hello
I use the touchscreen.
I want to be able to move my character.
So with someone else's help,
I've written the code.
We also connected touchscreen nodes to the kinematic body.
(pressured and released)
But it didn't work.
I want to know what went wrong in this code.
Help me.
extends KinematicBody2D
var velocity = Vector2()
func onup_pressed():
velocity.y -= 1
func onup_released():
velocity.y -= 1
func ondown_pressed():
velocity.y += 1
func ondown_released():
velocity.y += 1
func onright_pressed():
velocity.x += 1
func onright_released():
velocity.x += 1
func onleft_pressed():
velocity.x -= 1
func onleft_released():
velocity.x -= 1
(The touchscreen is also enabled with the mouse.)