I’ve been working on a REALLY complex finite state machine for the creature in my horror game.
My reference point is something like alien: isolation’s AI. the creature runs multiple layers of logic , all at once:
hearing , vision , noise investigation , memory of last known player positions , contextual pathfinding (using ladders , alternate routes).
I’m not sure if the server can handle this much , in a multiplayer setting. If anyone here worked with simple or complex FSMs , what was your approach ? Did it work out?
when you tag a function with native or put --!native at the beginning of a script, that code is compiled into machine code which is much faster than normal lua
but it also needs more strict typing than lua
example:
--!strict
-- position has to be typed as a Vector3 to use the speed advantage
-- because the code is trying to read position.X and position.Z, so it would be much slower if it doesn't know if position is a table or vector, but it wouldn't be slower in normal lua
@native local function groundPosition(position : Vector3)
return Vector3.new(position.X, 0, position.Z)
end
OR
--!strict
--!native
-- ^^^ automatically makes everything native when possible
local function groundPosition(position : Vector3)
return Vector3.new(position.X, 0, position.Z)
end