Jump to content

Detect Current Biome for Character?


Recommended Posts

I have a character who should get a speed boost while in swamps, while probably getting nerfed in other biomes as well. I know how to actually alter the movespeed, but I've searched all up and down the internet for any clues on biome checking. I could only find day,night based code. Thanks for any help.

Edited by AutumnPingo
Link to comment
Share on other sites

Here:

local function groundcheckfn(inst)
local tile = TheWorld.Map:GetTileAtPoint(inst.Transform:GetWorldPosition())
    if tile == GROUND.MARSH then
    inst.components.locomotor.walkspeed = 8 --higher speed
    inst.components.locomotor.runspeed = 10
    else
    inst.components.locomotor.walkspeed = 4 --regular speed
    inst.components.locomotor.runspeed = 6
    end
end

inst:DoPeriodicTask(1, groundcheckfn, nil, inst)

all this goes into the master_postinit and the last part of code goes near the onload code. Can't take much credit besides modifying the code from @ksaab and @SuperDavid  a bit back ago.

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