- Edited
I am currently making a 2D game with grid movement, but when I try to use tweens I always just come out confused, so that's why the issue might be painfully obvious. I cannot find a way to,
- Make a variable that equals 0 (on first movement) not come back as null.
- If there's a better way to use/make tweens.
This is the code
extends CharacterBody2D
var x = 0
var y = 0
var speed = 25
func _input(event):
if event.is_action_pressed("right"):
x = x + speed
position.x = x
var xprevpos = position.x - speed
position.y = y
var yprevpos = position.y - speed
var tween = create_tween()
tween.tween_property(xprevpos,"position",x,.2)