+1 vote

I'm new to Godot so Ive been following this (https://www.youtube.com/watch?v=mAbG8Oi-SvQ&list=PL9FzW-m48fn2SlrW0KoLT4n5egNdX-W9a) tutorial by Heartbeast on YouTube. I'm on part 13 which is on knockback and enemies, but after I type up the code and attack the enemy, the game crashes. Not sure what I'm doing wrong, so hopefully someone can help. Scripts are enclosed below:

ENEMY SCRIPT:
extends KinematicBody2D

var knockback = Vector2.ZERO

func physicsprocess(delta):
knockback = knockback.movetoward(Vector2.ZERO, 200 * delta)
knockback = move
and_slide(knockback)

func onHurtboxareaentered(area):
knockback = area.knockback_vector * 120

PLAYER SCRIPT:
extends KinematicBody2D

const FRICTION = 500
const ACCELERATION = 500
const ROLLSPEED = 125
const MAX
SPEED = 80

enum {
MOVE,
ROLL,
ATTACK
}

var velocity = Vector2.ZERO
var state = MOVE
var roll_vector = Vector2.LEFT

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

func ready():
animationTree.active = true
swordHitbox.knockback
vector = roll_vector

func physicsprocess(delta):

match state: 
    MOVE:
        move_state(delta)
    ROLL:
        roll_state(delta)
    ATTACK:
        attack_state(delta)

func movestate(delta):
var input
vector = Vector2.ZERO
inputvector.x = Input.getactionstrength("uiright") - Input.getactionstrength("uileft")
input
vector.y = Input.getactionstrength("uidown") - Input.getactionstrength("uiup")
inputvector = inputvector.normalized()

if input_vector != Vector2.ZERO:
    roll_vector = input_vector
    swordHitbox.knockback_vector = input_vector
    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("roll"):
    state = ROLL

if Input.is_action_just_pressed("attack"):
    state = ATTACK

func rollstate(delta):
velocity = roll
vector * ROLL_SPEED
animationState.travel("Roll")
move()

func attack_state(delta):
velocity = Vector2.ZERO
animationState.travel("Attack")

func move():
velocity = moveandslide(velocity)

func rollanimationfinished():
velocity = velocity * .9
state = MOVE

func attackanimationfinished():
state = MOVE

SWORD HITBOX:

extends Area2D

var knockback_vector = Vector2.ZERO

Once again, not sure what I'm doing wrong, and any help would be greatly appreciated. Thanks in advance.

Godot version 3.2.3
in Engine by (13 points)

Post the error message that godot gives you when it crashes

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.