I have only one print()
function in my game
It prints
4
This is the code where the print function is:
var d = direction
if !d == 4:
print(d)
The local variable var d
is only used in this lines of code
The variable direction is a variable that changes sometimes, but it is always between 0 and 7.
HOW IS IT POSSIBLE THAT IT PRINTS 4 SOMETIMES IF IT ONLY PRINTS WHEN
IT ISNT 4
My head will explod soon ;). Please help me!
Here is the whole script, also when I am not thinking that you will need it. It is the only script:
extends KinematicBody2D
export (int) var speed = 300
var direction = 4
var velocity = Vector2()
var spritedirection = "U"
func get_input():
velocity = Vector2(0,0)
var right = Input.is_key_pressed(KEY_D)
var left = Input.is_key_pressed(KEY_A)
var up = Input.is_key_pressed(KEY_W)
var down = Input.is_key_pressed(KEY_S)
if left:
velocity.x -= speed
if right:
velocity.x += speed
if up:
velocity.y -= speed
if down:
velocity.y += speed
func get_direction():
if !velocity == Vector2(0,0):
direction = rad2deg(velocity.angle()) / 45 + 3
func set_sprite():
if velocity == Vector2(0,0):
if $Animation.current_animation == "Laufen1":
$Animation.play("Stehen1")
if $Animation.current_animation == "Laufen3":
$Animation.play("Stehen3")
if $Animation.current_animation == "Laufen5":
$Animation.play("Stehen5")
if $Animation.current_animation == "Laufen7":
$Animation.play("Stehen7")
else:
var d = direction
if !d == 4:
print(d)
$Animation.play("Laufen"+str(d))
func _process(delta):
get_input()
get_direction()
set_sprite()
velocity = move_and_slide(velocity)