Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | PizzaOnFire99125 |
At the moment my character will slide around an object whenever I run into one(I don’t mean it’ll just go around it, I mean whenever I run into something it slides awkwardly. If you still don’t understand here’s a video file: https://cdn.discordapp.com/attachments/756466310526795817/785322586186711080/2020-12-06_20-50-45.mp4). It’s very disorienting and weird. I’ll put the code below this so if there is a way to add this I would greatly appreciate it.
const ACCELERATION = 500
const MAX_SPEED = 80
const FRICTION = 500
func move_state(delta):
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")
animationState.travel("Walk")
input_vector = input_vector.normalized()
if input_vector != Vector2.ZERO:
animationTree.set("parameters/Idle/blend_position", input_vector)
animationTree.set("parameters/Walk/blend_position", input_vector)
animationTree.set("parameters/Attack/blend_position", input_vector)
velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)
else:
animationState.travel("Idle")
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
velocity = move_and_slide(velocity)