Jump to content

Recommended Posts

Hopefully an easy answer..

 

I have a character that can dig under the ground, like a moleworm. While underground, I want him to have no world collision, being able to pass 'under' walls and such.

 

I thought it would be as simple as removing the physics strings in the function that determines above and under ground.

 

 local function SetState(inst, state)
    --"under" or "above"
    inst.State = string.lower(state)
    if inst.State == "under" then
        -- inst.Physics:SetCollisionGroup(COLLISION.CHARACTERS)
        -- inst.Physics:ClearCollisionMask()
        -- inst.Physics:CollidesWith(COLLISION.WORLD)
        -- inst.Physics:CollidesWith(COLLISION.OBSTACLES)
        inst.task = inst:DoPeriodicTask(0.2, function()
         SpawnPrefab("mole_move_fx").Transform:SetPosition(inst:GetPosition():Get())end)
    elseif inst.State == "above" then
        ChangeToCharacterPhysics(inst)
        inst.task:Cancel()
    end
end

 

 

But it retains normal collision even without these included. No clue what to change and nothing in the game far as I can see, behaves without collision.  Helps?

Link to comment
https://forums.kleientertainment.com/forums/topic/58363-collision-help/
Share on other sites

inst.Physics:ClearCollisionMask()

What do you think this does?

 

What the commented out code does is removes all collisions, then adds back some specific ones.

 

So you need to clear it again, and just not add it back.

 

Be careful though, for example don't let him go in water. The game crashes if you touch the edge of the world.

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