Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Amateur.game.dev. |
Basically I just reimported my sprites so that they could look smoother, but as soon as I did that my speed went from 100 to like 1000 in 1 second. Here is the entire script for the kinemtic2D node.
extends KinematicBody2D
export (int) var gravity = 200.0
export (int) var speed = 1
export (int) var jump_speed = -150
export (float) var max_health = 100
onready var health = max_health setget _set_health
onready var invulnerability_timer = $InvulnerabilityTimer
onready var effects_animation = $EffeectsAnimation
var input_vector = Vector2.ZERO
var life = 50
var velocity = Vector2.ZERO
signal health_changed(health)
signal killed()
func get_input():
if Input.is_action_pressed("walk_right"):
$PlayerSprite.play("Run2")
velocity.x += speed
elif Input.is_action_pressed("walk_left"):
$PlayerSprite.play("Run")
velocity.x -= speed
else:
$PlayerSprite.play("Idle")
velocity.x = 0
if Input.is_action_pressed("Reset"):
get_tree().reload_current_scene()
func _physics_process(delta):
get_input()
velocity.y += gravity * delta
move_and_slide(velocity, Vector2.UP)
if is_on_floor():
if Input.is_action_pressed("jump"):
velocity.y = jump_speed
func damage(amount):
if invulnerability_timer.is_stopped():
invulnerability_timer.start()
_set_health(health - amount)
effects_animation.play("InvulnerabilityPlayer")
effects_animation.queue("flash")
func kill():
pass
func _set_health(value):
var prev_health = health
health = clamp(value, 0, max_health)
if health != prev_health:
emit_signal("health_updated", health)
if health == 0:
kill()
emit_signal("killed")
func _on_ImmunityTimer_timeout():
effects_animation.play("rest")