Jump to content

How to use follower's walk(/run)speed


Recommended Posts

Hello, there!

 

I was wondering if anyone knew how to make your follower use its walkspeed when wandering and its runspeed when following the leader (or chasing or whatever, just let it use the walkspeed only when wandering like a pigman). Beware, I don't want the follower to use runspeed when the creature is beeing a follower, I want the follower to only use it when actually following. When wandering around me it should use its walkspeed. Hope I'm beeing clear here. :)

 

So far my followers are pretty much done but I just have this issue and I don't know what to do. Currently, both wandering and following speeds are set by the walkspeed. I can provide lua, stategraph and brain files if required.

 

I guess the stategraph might be the most useful thing (because I guess that way you can see what "type" of walking I'm using) so here is one :

SGcaterpillar_thibaud.lua

 

Thank you :)

 

Edit : pigs seem to use some kind of "common step" animation so they can walk when wandering and run when chasing/following. I don't understand how this works though. But if you do then you might want to have a look at it (at the very top).

SGpig.lua

Edited by Thibooms
Link to comment
Share on other sites

Wander makes the entity walk.

Follow has a "canrun" argument that allows your entity to follow.

If it's nil, then nil ~= false is true, and the entity will run when following you.

What is incomplete is that you don't have a running state on your stategraph.

I edited the locomotor event handler.

Also added a run state that uses the walk animations, but tells the guy to run forward, instead of walk forward.

SGcaterpillar_thibaud.lua

Link to comment
Share on other sites

11 hours ago, DarkXero said:

Wander makes the entity walk.

Follow has a "canrun" argument that allows your entity to follow.

If it's nil, then nil ~= false is true, and the entity will run when following you.

What is incomplete is that you don't have a running state on your stategraph.

I edited the locomotor event handler.

Also added a run state that uses the walk animations, but tells the guy to run forward, instead of walk forward.

SGcaterpillar_thibaud.lua

Thanks, that already clears up a lot. But regarding the "canrun" argument, do you mean that in order for the entity to run when following, this argument should be "true" like this (?) :

Follow(self.inst, function() return self.inst.components.follower.leader end, MIN_FOLLOW, MED_FOLLOW, MAX_FOLLOW, true),

Because that's the way it's set up in the brain yet when I use your stategraph he still goes at walkingspeed.

 

And just to be clear, I dit actually make sure to have the right walk/runspeeds in its lua :

    inst:AddComponent("locomotor")
    inst.components.locomotor.walkspeed = 3
    inst.components.locomotor.runspeed = 5

 

caterpillar_thibaudbrain.lua

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...