Jump to content

Recommended Posts

some items in Shipwrecked float while others sink.

It was easy enough to find the bit of code to make something float
       MakeInventoryFloatable(inst, "idle_water", "idle")

I went back into the item's scml and added an idle_water animation, and it works, the item floats and bobs in the water.
The problem is, other items have ripples that appear around them, but my items do not (see attached image).
This is not part of the other item's "idle_water" animation (I've checked those animations)
But is being added by the game to any item floating; any item, except mine apparently.
There doesn't appear to be anything special in the prefabs, other than the line above.

Does anyone know if there is something special that needs to be done to make these ripples appear?
 

Thank you

Ripples_1.jpg

Edited by MidrealmDM
punctuation error
Link to comment
https://forums.kleientertainment.com/forums/topic/69102-ripples-in-the-ocean/
Share on other sites

The file "flotable.lua" contains the following.. (among other things)

====
function Floatable:PlayWaterAnim()
    if not self.inst.AnimState:IsCurrentAnimation(self.wateranim or "") then
        self.inst.AnimState:SetLayer( LAYER_BACKGROUND )
        self.inst.AnimState:SetSortOrder( 3 )
        if self.wateranim then
            self.inst.AnimState:PlayAnimation(self.wateranim, true)
            self.inst.AnimState:SetTime(math.random())
        end
    end
    self.inst.AnimState:OverrideSymbol("water_ripple", "ripple_build", "water_ripple")
    self.inst.AnimState:OverrideSymbol("water_shadow", "ripple_build", "water_shadow")
end 

====

ripple_build.zip is in the anim folder

Converting it back to scml I find water_shadow folder and water_ripple folder with what appears to be the
images needed to build the ripple animation. There are also several animations stored, with key points on the timeline, but no images.

I suspect that somewhere, something controls how to build the ripples, based on the size of the floating object, but I am unable to find what or where.

Looking at the prefab boards.lua the only line that seems to have anything to do with floating is:
    MakeInventoryFloatable(inst, "idle_water", "idle")

So, I can only assume that whatever is controlling the build of these ripples is elsewhere.

Surely someone else has made something floatable by now, and can point me in the proper direction.

EDIT: standardcomponents.lua has the following:
function MakeRipples(inst)
    -- used if something has the ripple effects but it's an inventory item
    inst.AnimState:OverrideSymbol("water_ripple", "ripple_build", "water_ripple")
    inst.AnimState:OverrideSymbol("water_shadow", "ripple_build", "water_shadow")
end

function MakeInventoryFloatableWaterproof(inst, water_anim, land_anim)
    local water = water_anim or "idle_water"
    local land = land_anim or "idle"

    if inst.components.floatable == nil then
        inst:AddComponent("floatable")
    end
    inst.components.floatable.landanim = land
    inst.components.floatable.wateranim = water
end

function MakeInventoryFloatable(inst, water_anim, land_anim)
    MakeRipples(inst)
    MakeInventoryFloatableWaterproof(inst, water_anim, land_anim)
end

 

 

 

 

Edited by MidrealmDM
additional information

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