I have set animations in animation player and they work properly
for some reason game breaks after few loops following path2d and I dont know why.
its confusing because it makes few loops without problems but eventualy allways brakes
godot says an error is:
invalid operands string and nil in operator +
and points to a line in code:
var animation = "Walk" + animationdirection
What is confusing is that it works for a loop or to and than it breaks
onready var pathfollow = getparent()
var speed = 350
var move_direction = 0
var prepos = pathfollow.getglobalposition()
pathfollow.setoffset(pathfollow.getoffset() + speed * delta)
var pos = pathfollow.getglobalposition()
movedirection = (pos.angletopoint(prepos) / 3.14) * 180
if move_direction <= 15 and move_direction >= -15:
animation_direction = "E"
elif move_direction <= 60 and move_direction >= 15:
animation_direction = "SE"
elif move_direction <= 120 and move_direction >= 60:
animation_direction = "S"
elif move_direction <= 165 and move_direction >= 120:
animation_direction = "SW"
#elif move_direction <= 120 and move_direction >= 60:
#animation_direction = "S"
elif move_direction >= -60 and move_direction <= -15:
animation_direction = "NE"
elif move_direction >= -120 and move_direction <= -60:
animation_direction = "N"
elif move_direction >= -165 and move_direction <= -120:
animation_direction = "NW"
elif move_direction <= -165 and move_direction >= 165:
animation_direction = "W"
var animation = "Walk_" + animation_direction