This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

extends Node
class_name FiniteStateMachine

var states : Dictionary = {}
var previousstate: int = -1
var state: int = -1 setget set
state

onready var parent: Character = getparent()
onready var animation
player: AnimationPlayer = parent.get_node("AnimationPlayer")

func physicsprocess(delta: float) -> void:
if state != -1:
statelogic(delta)
var transition: int = gettransition()
if transition != -1:
set_state(transition)

func statelogic(_delte: float) -> void:
pass

func gettransition() -> int:
return -1

func addstate(newstate: String) -> void:
states[new
state] = states.size()

func setstates(newstate: int) -> void:
exitstates(state)
previousstate = state
state = new
state
enterstate(previous_state, state)

func enterstate(previousstates: int, _newstate : int) -> void:
pass

func exitstate(statedexited: int) -> void:
pass

Godot version 3.2.2
in Engine by (14 points)

1 Answer

0 votes

You defined setstates instead of setstate
function name must match exactly setter method of variable

by (8,188 points)
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 Frequently asked questions and 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 [email protected] with your username.