Basically, This problem have been really, really confusing and frustrating.
So I made a code so my character uses animations when using different keys on the keyboard.
BUUUUT it somehow made my character even faster and im like ?????
Here's my code for the character:
extends KinematicBody2D
#Variables and stuff
const Friction = 500
var Velocity = Vector2.ZERO
const MAX_SPEED = 80
onready var animationPlayer = $AnimationPlayer
enum{
MOVE,
ROLL,
ATTACK
}
var State = MOVE
onready var animationTree = $AnimationTree
onready var animationState = animationTree.get("parameters/playback")
func _ready():
animationTree.active = true
func _physics_process(delta):
match State:
ROLL:
pass
ATTACK:
attack_state(delta)
MOVE:
move_state(delta)
move_state(delta)
func move_state(delta):
#Movement Inputs
var input_vector = Vector2.ZERO
input_vector.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
input_vector.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
input_vector = input_vector.normalized()
#Thing that actually do the Movement
if input_vector != Vector2.ZERO:
animationTree.set("parameters/Idle/blend_position", input_vector)
animationTree.set("parameters/Run/blend_position", input_vector)
animationTree.set("parameters/Attack/blend_position", input_vector)
animationState.travel("Run")
Velocity = Velocity.move_toward(input_vector * MAX_SPEED, Friction * delta)
else:
animationState.travel("Idle")
#Complicated Meeeeeethsss
Velocity = Velocity.move_toward(Vector2.ZERO, Friction * delta)
Velocity = move_and_slide(Velocity)
if Input.is_action_pressed("attack"):
State = ATTACK
pass
func attack_state(delta):
animationState.travel("Attack")
pass
Any help would be greatly appreciated. Thanks in advance.