Jump to content

Need help coding brains for companion


Recommended Posts

when i was coding everything was working but the companion refuses to do anything and just sits there like a lemon

if you can help that would be awsome

 

 

require "behaviours/wander"
require "behaviours/faceentity"
require "behaviours/chaseandattack"
require "behaviours/panic"
require "behaviours/runaway"


local MAX_CHASE_TIME = 15
local WANDER_DIST = 20

local RUN_AWAY_DIST = 0
local STOP_RUN_AWAY_DIST = 3
local START_FACE_DIST = 5
local KEEP_FACE_DIST = 8
local MIN_FOLLOW_DIST = 1.5
local MAX_FOLLOW_DIST = 6
local MAX_WANDER_DIST = 1
local TARGET_FOLLOW_DIST = 3


local function GetFaceTargetFn(inst)
    return inst.components.follower.leader
end

local function KeepFaceTargetFn(inst, target)
    return inst.components.follower.leader == target
end

local PerdBrain = Class(Brain, function(self, inst)
    Brain._ctor(self, inst)
end)


--------------------------------------------------------------------------

function PerdBrain:OnStart()
    local root = PriorityNode(
    {
        ChaseAndAttack(self.inst, MAX_CHASE_TIME),
        Follow(self.inst, function()return self.inst.components.follower.leader end, MIN_FOLLOW_DIST, TARGET_FOLLOW_DIST, MAX_FOLLOW_DIST),
        FaceEntity(self.inst, GetFaceTargetFn, KeepFaceTargetFn),
    }, .25)

    self.bt = BT(self.inst, root)
end

return PerdBrain

Edited by thomas4845
forgot something
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...