#Godot 2D Movement locked to a grid Issues

10 messages · Page 1 of 1 (latest)

gusty crystal
#

@odd imp Not familiar with the game but if it's kind of grid based movement, say where character travels to each square before being able to travel to the next square...

With this, it seems that you've done that, so the movement seems to be the issue.

Do have collisions that could be an issue? Could be possible because you're using a character body. They require the moment to be done with velocity and changed with move _and_slide() and preferably inside _physics_process(delta)

If you expect that the character will not receive collisions you could use an area instead.

Also, in input, immediately set moving to true once you determine it's true. That way it quits processing instantly.

odd imp
#

I think the issues might be stemming from the fact it processes an entire "movement" and then resets the process but im not sure

#

I feel like I might end up having to rewrite the whole thing

gusty crystal
#

How are you determining the size of the tile movement? If the movement is not large enough for the character to the world, it may look like tiny jittery movement.

odd imp
#

with the tile_size variable

gusty crystal
#

I mean are you using a tilemap or just moving it based on the size?

odd imp
#

I think based on the size?

gusty crystal
#
@onready var moving: bool = false

func _process(delta):
    if !moving:
        moving = true
        move_sprite()
    

func move_sprite():
    var newTween: Tween = create_tween().set_trans(Tween.TRANS_LINEAR)
    newTween.tween_property($Sprite2D, "position", $Sprite2D.position + Vector2(64, 0), 0.08)
    await newTween.finished
    # Added another just to pause the movement a bit.
    var timerTween: Tween = create_tween()
    timerTween.tween_interval(1.0)
    await timerTween.finished
    moving = false
    
#

You don't have to call this in process, but it's how I did it to show it's not processing even with the fastest process tick in Godot, Well input may be slightly faster, but I use this same case in my input methods.