Jump to content

Replacing running animations for one character (DST).


Recommended Posts

I have a character for dst. And I wanted the character to have a different animation of the start of the run, the run and the stop of the run. I found an article with the code:

AddStategraphPostInit("wilson", function(sg)
	local _run_onenter = sg.states.run.onenter
	local function GetRunStateAnim(inst)
    return (inst.sg.statemem.heavy and "heavy_walk")
        or (inst.sg.statemem.sandstorm and "sand_walk")
        or (inst.sg.statemem.groggy and "idle_walk")
        or (inst.sg.statemem.careful and "careful_walk")
        or "run"
	end
	sg.states.run.onenter = function(inst)
		_run_onenter(inst)
		if inst.prefab == "NamePrefab" and inst.AnimState:IsCurrentAnimation(GetRunStateAnim(inst).."_pre") then
			inst.AnimState:PlayAnimation("walk_pre")
		elseif inst.prefab == "NamePrefab" and inst.AnimState:IsCurrentAnimation("run") or inst.AnimState:IsCurrentAnimation("run_loop") then
			inst.AnimState:PlayAnimation("walk_loop")
		elseif inst.prefab == "NamePrefab" and inst.AnimState:IsCurrentAnimation(GetRunStateAnim(inst).."_pst") then
			inst.AnimState:PlayAnimation("walk_pst")
		end
		
	end
end)

This code works. But this code in modmain changes the walk animation for all characters. And yet he does not change the animation of the beginning of walking or running and the end of walking or running. I thought that inst.prefab == "NamePrefab", if I specify the prefab of my character, then the running animation will be applied only to my character, but it turns out to be wrong. I tried copying SGwilson to my mod’s folder, replacing the wilson with my character (I did the same with SGwilson_client) and added inst: SetStateGraph ("SGNamePrefab_client") inst: SetStateGraph ("SGNamePrefab"). It helped, but only for a world without caves. And in the world with caves, nothing works. 
The fact is that I do not understand stategraphs. I read articles on creating and downloaded mods to create my own animation. But neither of which worked for me. I just want my character to have its own animation of walking and running (start_run and stop_run and run), and not everyone, without creating new stategraphs. Can you help me?

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