Jump to content

Recommended Posts

I've been looking though Shipwrecked scripts and animation files, but haven't quite figured out how were boats animations handled. As far as know it is part of the player animation and the actual boat entity itself is hidden when mounted, but I can't find the anim.bin file for boat animations, or any boat symbols I can override.

Does anyone know how were those created and how to make custom animations compatible with boats?

Edited by _zwb

Snipaste_2023-09-13_12-02-04.thumb.png.4a4c714a8198c96eda809f9bcfed8834.png

这是包含了所有图片的scml动画预览,但是我没有相应的技术来制作动画。如果你能写一个和spine互转的还有戏,否则目前没有办法直接编辑动画,需处理xml或json格式的矩阵数据。

  • Thanks 1

I know an... unconventional method of making the boats appear on custom animations:
By using inst.components.driver:SplitFromVehicle() and inst.components.driver:CombineWithVehicle() you can visually make the boat appear under the Player's feet, these two functions are purely visual and will not actually dismount the Player from their boat. So, I'll give you an example below:

AddStategraphState("wilsonboating", GLOBAL.State {
		name = "perusal",
		tags = {"doing", "busy", "boating"},

		onenter = function(inst)
			inst.components.locomotor:StopMoving()
			inst.SoundEmitter:PlaySound("dontstarve/wilson/attack_whoosh", nil, .1)
			inst.components.driver:SplitFromVehicle()	-- Visually split the boat from the Player!
			inst.AnimState:OverrideSymbol("book_cook", "wilson_journal", "book_wilson")
			inst.AnimState:PlayAnimation("reading_in")
			inst.AnimState:PushAnimation("reading_loop", true)
			
			local downvec = TheCamera:GetDownVec()
			local facedown = -(math.atan2(downvec.z, downvec.x) * (180/math.pi))
			inst.components.driver.vehicle.Transform:SetRotation(facedown)	-- Use this if you want the boat to face down!

			local timeout = math.random(1.2, 1.4)
			inst.sg:SetTimeout(timeout)
		end,

		onexit = function(inst)
			inst.components.driver:CombineWithVehicle()	-- Onexit make the boat combine back with the Player!
		end,

		timeline =
		{
			TimeEvent(8 * FRAMES, function(inst)
				inst.sg:RemoveStateTag("busy")
			end),
		},

		ontimeout= function(inst)
			inst:PerformBufferedAction()
			inst.sg:GoToState("perusal_pst")
		end,
	}
)

This is the code I used on the Wilson's New Horizons mod for the reading_loop animation from DST, I properly made use of the two functions SplitFromVehicle on onenter and CombineWithVehicle on onexit. You can also use this on onenter:

	local downvec = TheCamera:GetDownVec()
	local facedown = -(math.atan2(downvec.z, downvec.x) * (180/math.pi))
	inst.components.driver.vehicle.Transform:SetRotation(facedown)	-- Use this if you want the boat to face down!

To make the boat face the camera.

Edited by mathem99
  • Thanks 1
5 hours ago, mathem99 said:

I know an... unconventional method of making the boats appear on custom animations:
By using inst.components.driver:SplitFromVehicle() and inst.components.driver:CombineWithVehicle() you can visually make the boat appear under the Player's feet, these two functions are purely visual and will not actually dismount the Player from their boat. So, I'll give you an example below:

AddStategraphState("wilsonboating", GLOBAL.State {
		name = "perusal",
		tags = {"doing", "busy", "boating"},

		onenter = function(inst)
			inst.components.locomotor:StopMoving()
			inst.SoundEmitter:PlaySound("dontstarve/wilson/attack_whoosh", nil, .1)
			inst.components.driver:SplitFromVehicle()	-- Visually split the boat from the Player!
			inst.AnimState:OverrideSymbol("book_cook", "wilson_journal", "book_wilson")
			inst.AnimState:PlayAnimation("reading_in")
			inst.AnimState:PushAnimation("reading_loop", true)
			
			local downvec = TheCamera:GetDownVec()
			local facedown = -(math.atan2(downvec.z, downvec.x) * (180/math.pi))
			inst.components.driver.vehicle.Transform:SetRotation(facedown)	-- Use this if you want the boat to face down!

			local timeout = math.random(1.2, 1.4)
			inst.sg:SetTimeout(timeout)
		end,

		onexit = function(inst)
			inst.components.driver:CombineWithVehicle()	-- Onexit make the boat combine back with the Player!
		end,

		timeline =
		{
			TimeEvent(8 * FRAMES, function(inst)
				inst.sg:RemoveStateTag("busy")
			end),
		},

		ontimeout= function(inst)
			inst:PerformBufferedAction()
			inst.sg:GoToState("perusal_pst")
		end,
	}
)

This is the code I used on the Wilson's New Horizons mod for the reading_loop animation from DST, I properly made use of the two functions SplitFromVehicle on onenter and CombineWithVehicle on onexit. You can also use this on onenter:

	local downvec = TheCamera:GetDownVec()
	local facedown = -(math.atan2(downvec.z, downvec.x) * (180/math.pi))
	inst.components.driver.vehicle.Transform:SetRotation(facedown)	-- Use this if you want the boat to face down!

To make the boat face the camera.

I've tried showing boat entity before making this post, it sort of works but the issue is the boat itself isn't at the same position as the boat in player's animation:wilsondisappointed: Any ideas how to solve that? Maybe I could move the boat a bit to fit the animation?

35 minutes ago, _zwb said:

I've tried showing boat entity before making this post, it sort of works but the issue is the boat itself isn't at the same position as the boat in player's animation:wilsondisappointed: Any ideas how to solve that? Maybe I could move the boat a bit to fit the animation?

Hmm... the only thing I can think of is making the boats be a little upwards in their idle state (whenever the player isn't riding it/when you split it with inst.components.driver:SplitFromVehicle() so this should work:
 

AddComponentPostInit("driver", function(self)
    local _OnUpdate = self.OnUpdate
    function self:OnUpdate(dt)
        _OnUpdate(self, dt)
        if self.vehicle ~= nil and self.vehicle:IsValid() then
            local CameraRight = GLOBAL.TheCamera:GetRightVec()
            local CameraDown = GLOBAL.TheCamera:GetDownVec()

            local myPos = self.inst:GetPosition()
            local displacement = CameraRight:Cross(CameraDown) * 0.05

            local pos = myPos - displacement

            self.vehicle.Transform:SetPosition(pos:Get())
        end
    end
end)

Try it with this on your modmain.lua

On 9/13/2023 at 1:02 PM, mathem99 said:

Hmm... the only thing I can think of is making the boats be a little upwards in their idle state (whenever the player isn't riding it/when you split it with inst.components.driver:SplitFromVehicle() so this should work:
 

AddComponentPostInit("driver", function(self)
    local _OnUpdate = self.OnUpdate
    function self:OnUpdate(dt)
        _OnUpdate(self, dt)
        if self.vehicle ~= nil and self.vehicle:IsValid() then
            local CameraRight = GLOBAL.TheCamera:GetRightVec()
            local CameraDown = GLOBAL.TheCamera:GetDownVec()

            local myPos = self.inst:GetPosition()
            local displacement = CameraRight:Cross(CameraDown) * 0.05

            local pos = myPos - displacement

            self.vehicle.Transform:SetPosition(pos:Get())
        end
    end
end)

Try it with this on your modmain.lua

This works for me, just need to change the number a bit so the animation match

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
×
  • Create New...