how to differntiate between is_action_just_pressed and is_action_pressed

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By infinity10004

during the development a rpg style game I came across a issue in the player script when we press hold a button the player moves a tile from its initial position, while I was trying to add turning to the character script I tried too simply make the character turn if we just pressed a button but instead it would just move normally it looks like godot isn’t able to tell the difference between an is_action_just_pressed and is_action_pressed any suggestions how i can fix it or an alternative to it

here is the code that i have used

extends KinematicBody2D

export var walk_speed = 4.0
const tile_size = 16

var velocity = Vector2()
var initial_position = Vector2(0,0)
var input_direction = Vector2(0,0)
var is_moving = false
var percent_moved_to_next_tile = 0.0
var can_move = true
var has_running_shoes = true
var is_running = false
var is_turning = false

onready var anim_player = $AnimatedSprite

var current_direction

func _ready():
	initial_position = position
	velocity = position

func _physics_process(delta):
	if Input.is_action_pressed("decline") and can_move and has_running_shoes:
		walk_speed = 8.0
		is_running = true
		walk_speed = 4.0
		is_running = false
	if Input.is_action_just_pressed("D"):
		is_turning = true
		is_turning = false
	if input_direction.y == 1 and can_move:
		if is_running == false:"walk_down")
			current_direction = "down"
		elif is_running == true:"run_down")
			current_direction = "down"
	elif input_direction.y == -1 and can_move:
		if is_running == false:"walk_up")
			current_direction = "up"
		elif is_running == true:"run_up")
			current_direction = "up"
		if current_direction == str("down") and can_move:"idle_1")
		elif current_direction == str("up") and can_move:"idle_3")
	if input_direction.x == 1 and can_move and is_turning == false:
		if is_running == false:"walk_right")
			current_direction = "right"
		elif is_running == true:"run_right")
			current_direction = "right"
	elif input_direction.x == -1 and can_move and is_turning == false:
		if is_running == false:"walk_left")
			current_direction = "left"
		elif is_running == true:"run_left")
			current_direction = "left"
		if current_direction == str("right") and can_move:"idle_2")
		elif current_direction == str("left") and can_move:"idle_4")
	if is_moving == false:
	elif input_direction != Vector2.ZERO:
		is_moving = false

func process_player_input():
	if input_direction.y == 0:
		input_direction.x = int(Input.is_action_pressed("D")) - int(Input.is_action_pressed("A"))
	if input_direction.x == 0:
		input_direction.y = int(Input.is_action_pressed("S")) - int(Input.is_action_pressed("W"))
	if input_direction != Vector2.ZERO:
		initial_position = position
		is_moving = true

func move(delta):
	percent_moved_to_next_tile += walk_speed * delta
	if percent_moved_to_next_tile >= 1:
		position = initial_position + (tile_size * input_direction)
		percent_moved_to_next_tile = 0.0
		is_moving = false
		position = initial_position + (tile_size * input_direction * percent_moved_to_next_tile)

so any idea how i can implement turning mechanism if yes the please reply

:bust_in_silhouette: Reply From: Inces

Action just pressed is exactly like action pressed but without echo. Since You check it in process() it is true at first frame pressing button, and after that it becomes false. I can’t really imagine how You want this turning to work and look, but You just have to design clear borders of when it is true and when it becomes false. Like it is true when action is just pressed but becomes false when character finishes movement on tile or when action is released.