Jump to content

How to make Wilbur run toggleable


Recommended Posts

Hello everyone, I'm new to modding and want to make a simple change to wilbur: press a button to toggle between walking and running.

I know how he goes to walking state to running state, but don't know how to make it toggleable. Could someone please help me?

Link to comment
Share on other sites

So, I didn't know how to toggle it, but I made a simpler and smoothier solution: If Wilbur is walking for 3 seconds AND you press right click button, he starts running. Now you have the option to walk indefinitely (my main objective) and start running whenever it pleases you.

I changed the original code, without doing any mods, by going on SGwilson.lua and just adding "TheInput:IsMouseDown(MOUSEBUTTON_RIGHT)" on the run state. My addition is commented to highlight it to everyone.

 

 State{
        
        name = "run",
        tags = {"moving", "running", "canrotate"},
        
        onenter = function(inst) 
            inst.components.locomotor:RunForward()
            inst.AnimState:PlayAnimation("run_loop")
        end,

        onupdate = function(inst)
            inst.components.locomotor:RunForward()
            if inst.components.locomotor.timemoving >= TUNING.WILBUR_TIME_TO_RUN and --[[TheInput:IsMouseDown(MOUSEBUTTON_RIGHT)--]] and  inst:HasTag("monkey") and not inst.components.rider:IsRiding() then
               inst.sg:GoToState("run_monkey_start") 
            end
        end,

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...