system
December 8, 2019, 9:17pm
1
Attention
Topic was automatically imported from the old Question2Answer platform.
Asked By
darkside2922
I am working and when loading a scene it shows me the following error 0: 00: 00: 664 and 0: 00: 00: 0136 help me to fix it.
extends KinematicBody2D
const speed = 50
var anim = “”
var Animaction
var nira = “”
func _ready():
Animacion = get_node(“AnimationPlayer”)
set_physics_process(true)
func fixed_process(delta):
var direction = Vector2()
var new_anim = anim
if Input.is_action_pressed("ui_down"):
direction.y += speed
new_anim = "down"
nira = "down"
elif Input.is_action_pressed("ui_up"):
direction.y += -speed
nira = "up"
elif Input.is_action_pressed("ui_left"):
direction.x += -speed
new_anim = "left"
nira = "left"
elif Input.is_action_pressed("ui_right"):
direction.x += speed
new_anim = "right"
nira = "right"
else:
new_anim = ""
Animacion.stop();
if new_anim != anim:
anim = new_anim
Animaction.play(anim)
var movement = direction.normalized() * speed * delta
move(motion)
you call fixed_process
instead of _physics_process
go through your scripts and check for typos and such
rustyStriker | 2019-12-08 22:02
Also, “0: 00: 00: 664” and “0: 00: 00: 0136” are not error codes; they’re timestamps. The actual error message is displayed at the right of the timestamp.
Calinou | 2019-12-09 18:05
system
December 9, 2019, 3:34am
2
Reply From:
ItsYoBoi
If you are trying to write some code to get your player to move along with an animated sprite, I can offer you mine. It works perfectly, you just need to changed the animated sprite “names” for it. If you are making a 2D game, I also have some code that flips the character and its animations depending on which way you are going.
extends KinematicBody2D
const SPEED = 250
const GRAVITY = 10
const GRAVITY2 = 100
const JUMP_POWER = -500
const FLOOR = Vector2(0, -1)
var velocity = Vector2()
var jump = false
var jump_speed = 10
var on_ground = false
var can_move = true
var is_attacking = false
func _physics_process(delta):
if Input.is_action_pressed("forward"):
if is_attacking == false || is_on_floor() == false:
velocity.x = SPEED
if is_attacking == false:
$AnimatedSprite.play("run")
$AnimatedSprite.flip_h = false
if sign($Position2D.position.x) == -1:
$Position2D.position.x *= -1
elif Input.is_action_pressed("backward"):
if is_attacking == false || is_on_floor() == false:
velocity.x = -SPEED
if is_attacking == false:
$AnimatedSprite.play("run")
$AnimatedSprite.flip_h = true
if sign($Position2D.position.x) == 1:
$Position2D.position.x *= -1
else:
velocity.x = 0
if on_ground == true && is_attacking == false:
$AnimatedSprite.play("idle")
if Input.is_action_pressed("jump"):
if is_attacking == false:
if on_ground == true:
velocity.y = JUMP_POWER
$AnimatedSprite.play("jump")
on_ground == false