Wall and Slope Testing in Core

Wall and Slope Testing in Core post thumbnail image

Testing to see what is the maximum extreme walkable slope angle and then starting to test a code to walk on walls. This, so far, uses a trigger for the player to change his rotation to snap to the wall upon touching the wall; no walking yet. Player releases from wall with SPACE.

For the ability to walk up the most extreme slopes I set Third Person Player Settings: Walkable Floor Angle to: 55.

For the ability to step up high (blocks) I set (upon player join) player.stepHeight = 400 (server context).

Below: Walkable Wall trigger script. This is within a Client Context.

local trigger = script.parent

function OnBeginOverlap(trigger,other)
    -- must do local player check in client context (errors on multiple players)
    if other:IsA("Player") and other.name == Game.GetLocalPlayer().name then
        _G["gbon"] = true
        Events.BroadcastToServer("GBCheck",trigger.name)
    end
end


function OnEndOverlap(trigger,other) -- using Jump (SPACE) to detach now..
    if(other:IsA("Player"))then
        _G["gbon"] = false
        --Events.BroadcastToServer("GBStop",trigger.name) -- stops touching the wall
    end
end

trigger.beginOverlapEvent:Connect(OnBeginOverlap)
trigger.endOverlapEvent:Connect(OnEndOverlap)

Below: Main (Client Context) script

_G["gbon"] = false

function OnBindingPressed(player, binding) -- keys are being pressed!

    if(binding == "ability_extra_21")then -- W (up)
        --_moveFMVertical(-1)
        UI.PrintToScreen("W")
    end
    if(binding == "ability_extra_30")then -- A (left)
        --_moveFMHorizontal(-1)
        UI.PrintToScreen("A")
    end
    if(binding == "ability_extra_31")then -- S (down)
        --_moveFMVertical(1)
        UI.PrintToScreen("S")
    end
    if(binding == "ability_extra_32")then -- D (right)
        --_moveFMHorizontal(1)    
        UI.PrintToScreen("D")
    end
    if(binding == "ability_extra_17")then -- (SPACE)
        if(_G["gbon"])then -- detach from wall
            Events.BroadcastToServer("GBStop")
        end
    end      
     -- RIGHT MOUSE spawns items for the Follow Menu
    if(binding == "ability_secondary")then
        UI.PrintToScreen("RMouse")
    end  
end

Game.playerJoinedEvent:Connect(function(player)
    player.bindingPressedEvent:Connect(OnBindingPressed)
end)

And, finally, the Main (Server Context) Script:

local defAnimStance = nil
local defRotation = nil
local defJumpVelocity = nil
-- switch player's movement on/off
local _playerSwitch = {nil}
_playerSwitch[0] = MovementControlMode.NONE
_playerSwitch[1] = MovementControlMode.VIEW_RELATIVE


function GBCheck(player,tname) -- check Gravity Boots hitting a wall
    if(player.isJumping == false) then -- player can't be jumping for this
        print("GB Check for "..player.name.." from wall trigger: "..tname)
        --_spawnTo = World.FindObjectByName("spawncube"..tostring(tname + 1)):GetWorldPosition() + Vector3.New(0,0,25)
        --_rotateTo = World.FindObjectByName("spawncube"..tostring(tname + 1)):GetWorldRotation()
        --player:ActivateFlying()
        --defRotation = player:GetWorldRotation()
        player.movementControlMode = _playerSwitch[0]
        --player.animationStance = "unarmed_walk_forward"
        player.canMount = false -- true/false => disallow mounting ability for now
        player.isCrouchEnabled = false -- true/false => disallow crouching for now
        player.maxJumpCount = 0 -- 0 or 1 -- disable jumping for now
        player.jumpVelocity = 100
        player:SetWorldRotation(player:GetWorldRotation() + Rotation.New(0, 90, 0))
        --Task.Wait(3)
        --player:AddImpulse(Vector3.RIGHT * player.mass * 500)
    end
end

function GBStop(player) -- check Gravity Boots stop working
    print("GB Stop for "..player.name)
    --player:ActivateWalking()
    player:SetWorldRotation(defRotation)
    player.animationStance = defAnimStance
    player.movementControlMode = _playerSwitch[1]
    player.canMount = true -- true/false =>
    player.isCrouchEnabled = true -- true/false => 
    Task.Wait(.5) -- keeps "jump" from activating
    player.maxJumpCount = 1 -- 0 or 1
    player.jumpVelocity = defJumpVelocity
end

Events.ConnectForPlayer("GBCheck", GBCheck)
Events.ConnectForPlayer("GBStop", GBStop)

Game.playerJoinedEvent:Connect(function(player)
    player.stepHeight = 400
    defAnimStance = player.animationStance
    defRotation = player:GetWorldRotation()
    defJumpVelocity = player.jumpVelocity
end)

Tags: , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

Latest Posts

Emulation ProcessEmulation Process

  Record Locs for Emulation in Core Grab data. Here, I am recording x,yz, and name data to emulate. Next Convert to usable array for Core template data. Snippet>> Pattern  Core template replacement pattern: Path:[C:\Users\soandso\Documents\My Games\CORE\Saved\Maps\mycoregame\Data\Tree\Emulator_