So I am following Heart Beast's action RPG series, and I've noticed an issue. When my player collides with my bushes, the player sometimes sticks to it if I'm moving diagonally into the curved side of the bush, and sometimes the character "bounces" off the bush mush faster than normal. I don't know how long it has been present, but I don't know how to fix it.

Below is the code and a video of the issue:

extends KinematicBody2D

const max_Speed = 100
const acceleration = 500
const friction = 500

enum {
	move,
	roll,
	attack
}

var state = move
var velocity = Vector2.ZERO
var roll_vector = Vector2.DOWN

onready var animationPlayer = $AnimationPlayer
onready var animationTree = $AnimationTree
onready var animationState = animationTree.get("parameters/playback")

func _ready():
	animationTree.active = true

func _physics_process(delta):
	match state:
		move:
			move_state(delta)
		
		roll:
			roll_state(delta)
		
		attack:
			attack_state(delta)

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")
	input_vector = input_vector.normalized()
	roll_vector = input_vector
	
	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)
		animationTree.set("parameters/Roll/blend_position", input_vector)
		animationState.travel("Run")
		
		velocity = velocity.move_toward(input_vector * max_Speed, acceleration * delta)
	
	else:
		animationState.travel("Idle")
		velocity = velocity.move_toward(Vector2.ZERO, friction * delta)
	
	move()
	
	if Input.is_action_just_pressed("attack"):
		state = attack
	
	if Input.is_action_just_pressed("roll"):
		state = roll
	
func attack_state(delta):
	velocity = Vector2.ZERO
	animationState.travel("Attack")

func roll_state(delta):
	animationState.travel("Roll")
	velocity = roll_vector * max_Speed * 1.5
	move()

func move():
	velocity = move_and_slide(velocity)

func roll_animation_finished():
	velocity = velocity * 0.75
	state = move

func attack_animation_finished():
	state = move

Here is a link to a video of the problem

    I have to figure out the nuances of that but generally to normalize diagonal movement you want to use .normalize() to solve diagonal speed issues, which i don’t see in your code.

    The reason why is because the movement values of x and y ‘stack’ in this configuration of inputs, meaning the x and y speeds combine to double movement speed. Davidepesce.com wrote a great blog post about it in his Godot RPG tutorial.

    Somewhere in the code (probably physics process) you will want to add:
    velocity = velocity.normalized() or something along that line. This brings the movement to a normal value.

    Or you can slot this into your move state somewhere:

    If abs(input_vector_x) + abs(input_vector_y) > 1:
          velocity = velocity.normalized()

    Considering that hitting a bush diagonally is doing this weirdness, this may be the culprit. Abs rounds the value and, if x and y combine into that stacked value, this causes the movement to even out.

    OceanMan11235

      SnapCracklins
      I have input_vector = input_vector.normalized() in the 4th line of the code. The tutorial I'm following adds that line in to normalize the diagonal velocity, but it is never used to solve the problem I have

      Also won't normalizing the velocity make my acceleration variable useless, because normalizing the velocity makes it constant?

      I've also noticed that when it jitters forward, the velocity never increases past my max speed (100), which makes no sense since it clearly goes faster

      I've put the, if abs(input_vector.x) + abs(input_vector.y) > 1:
      velocity = velocity.normalized(), into my code, but that hasn't helped at all.

      Someone from the discord helped me 🙂. It ended up being that the shape of my collisions were messed up.