_zwb Posted September 12, 2023 Share Posted September 12, 2023 (edited) 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 September 12, 2023 by _zwb Link to comment https://forums.kleientertainment.com/forums/topic/150925-how-is-the-boat-animation-handled-in-shipwrecked/ Share on other sites More sharing options...
Rickzzs Posted September 13, 2023 Share Posted September 13, 2023 这是包含了所有图片的scml动画预览,但是我没有相应的技术来制作动画。如果你能写一个和spine互转的还有戏,否则目前没有办法直接编辑动画,需处理xml或json格式的矩阵数据。 1 Link to comment https://forums.kleientertainment.com/forums/topic/150925-how-is-the-boat-animation-handled-in-shipwrecked/#findComment-1664846 Share on other sites More sharing options...
mathem99 Posted September 13, 2023 Share Posted September 13, 2023 (edited) 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 September 13, 2023 by mathem99 1 Link to comment https://forums.kleientertainment.com/forums/topic/150925-how-is-the-boat-animation-handled-in-shipwrecked/#findComment-1664852 Share on other sites More sharing options...
_zwb Posted September 13, 2023 Author Share Posted September 13, 2023 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 Any ideas how to solve that? Maybe I could move the boat a bit to fit the animation? Link to comment https://forums.kleientertainment.com/forums/topic/150925-how-is-the-boat-animation-handled-in-shipwrecked/#findComment-1664873 Share on other sites More sharing options...
mathem99 Posted September 13, 2023 Share Posted September 13, 2023 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 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 Link to comment https://forums.kleientertainment.com/forums/topic/150925-how-is-the-boat-animation-handled-in-shipwrecked/#findComment-1664876 Share on other sites More sharing options...
Rickzzs Posted September 14, 2023 Share Posted September 14, 2023 如果你要用代码的话那就是播anim时判断当前build有没有船符号,没有就生成一个船挂到实体背后,然后同步播放动画,监听animdone隐藏这个船。 Link to comment https://forums.kleientertainment.com/forums/topic/150925-how-is-the-boat-animation-handled-in-shipwrecked/#findComment-1665033 Share on other sites More sharing options...
_zwb Posted September 15, 2023 Author Share Posted September 15, 2023 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 Link to comment https://forums.kleientertainment.com/forums/topic/150925-how-is-the-boat-animation-handled-in-shipwrecked/#findComment-1665288 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now