• Godot HelpGodot 4.X
  • "Invalid operands 'Vector2' and 'float' in operator '+'." Error, Godot 4.1.2

I am new to coding and Godot and while I was watching a tutorial I got to the actually coding the movement of the character it just doesn't work. I copied the exact code and it just crashes. Anyone that can help?
This is my code

extends CharacterBody2D

`@export`` var move_speed : float = 100

func physics_process(delta):
var input_direction = Vector2(
Input.get_action_strength("right") - Input.get_action_strength("left"),
Input.get_action_strength("down") - Input.get_action_strength("up")
)

velocity = input_direction + move_speed

move_and_slide()`
  • xyz replied to this.
  • PiplupPrince Are you sure tutorial said to use addition here?

    velocity = input_direction + move_speed

    Perhaps check again if it isn't saying to multiply them:

    velocity = input_direction * move_speed

    PiplupPrince Are you sure tutorial said to use addition here?

    velocity = input_direction + move_speed

    Perhaps check again if it isn't saying to multiply them:

    velocity = input_direction * move_speed

      xyz That fixed my issue thank you! It seems I miss read the code.