Hm, at that time it was making sense, but now i can't remember why... It's base on 2 or 3 different tutorials, i take pieces of them, try to understand, and make my code from it.
I'm doing a top down RPG adventure clan game... Looks like roguelike, with one main character, and later with kind of slaves, you cannot control them but can give orders like gather, patrol... and i want to have encounters (battle, trade...) in a kind of Fire Emblem view. I have no idea yet how to do the turn based part, and the IA part even less.
Well, i'm not there yet... Here is my progress over time : http://jeux1d100.net/forum/index.php?topic=4.0
I changed it for this and it seems to work perfectly well so far, and i the feeling is smoother too.
extends KinematicBody2D
var loc = Vector2(0,0)
var direction = Vector2(0,0)
const SPEED = 1
const GRID = 16
func _ready():
set_fixed_process(true)
func _fixed_process(delta):
if (Input.is_action_pressed("ui_up")):
direction = Vector2(0, -1)
loc = get_pos()
move_to(get_pos() +direction *SPEED)
if (Input.is_action_pressed("ui_down")):
direction = Vector2(0, 1)
loc = get_pos()
move_to(get_pos() +direction *SPEED)
if (Input.is_action_pressed("ui_left")):
direction = Vector2(-1, 0)
loc = get_pos()
move_to(get_pos() +direction *SPEED)
if (Input.is_action_pressed("ui_right")):
direction = Vector2(1, 0)
loc = get_pos()
move_to(get_pos() +direction *SPEED)