-
What do you want to achieve? Keep it simple and clear!
I want it so i can disable the default movement of the players humanoid and so i can move the character using my own custom logic like calculating gravity and the movedirection. like how other GameEngines like unity and unreal do it where you have a move() function and the vector that you put in there will actually be the characters velocity without background calculations of roblox. -
What is the issue? Include screenshots / videos if possible!
I dont know how to start on this or how to implement this -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried using the roblox custom physics controllers for this but it didnt meet my expectations, it gave the player a slide affect and the speed in the air and ground where different if you applied force. I also tried setting the velocity of the HumanoidRootPart but it gave me some weird results where my character went through the map and fell over
You could always apply a linearVelocity to the character, this will stop any physics stuff, such as gravity, and movement, then you could custom code it
could i maybe also try moving the character using humanoidRootPart.AssemblyLinearVelocity? and what would be the best runservice callback to use this maybe heartbeat or preanimation?
Hmm Im not sure, I’ve never used that but you could always try!
StarterPlayer/LocalPlayer DevComputerMovemendMode and DevTouchMovementMode both have a “scriptable” option, just like cameras
nevermind roblox is stupid
tldr solution:
local player = game.Players.LocalPlayer
local PlayerScripts = player.PlayerScripts
local PlayerModule = require(PlayerScripts.PlayerModule)
local controller = PlayerModule:GetControls()
controller.moveFunction = function() end
I ran into a similar problem. I looked through the default character movement script:
function ControlModule.new()
local self = setmetatable({},ControlModule)
-- The Modules above are used to construct controller instances as-needed, and this
-- table is a map from Module to the instance created from it
self.controllers = {}
self.activeControlModule = nil -- Used to prevent unnecessarily expensive checks on each input event
self.activeController = nil
self.touchJumpController = nil
self.moveFunction = Players.LocalPlayer.Move
self.humanoid = nil
self.lastInputType = Enum.UserInputType.None
self.controlsEnabled = true
-- For Roblox self.vehicleController
When a controller is created, it sets the moveFunction
to the player:Move()
method. Overwriting this to a do-nothing function should work since the logic handling the calculation of MoveVector is independent from actually moving the character.
You would have to get the controller in order to do this. This is the top level player module
--[[
PlayerModule - This module requires and instantiates the camera and control modules,
and provides getters for developers to access methods on these singletons without
having to modify Roblox-supplied scripts.
2018 PlayerScripts Update - AllYourBlox
--]]
local PlayerModule = {}
PlayerModule.__index = PlayerModule
function PlayerModule.new()
local self = setmetatable({},PlayerModule)
self.controls = require(script:WaitForChild("ControlModule"))
return self
end
function PlayerModule:GetControls()
return self.controls
end
return PlayerModule.new()
The default thing provides the GetControls method to get the controller, which you can index into to disable the move function
Put this in a localscript in StarterPlayerScripts:
local player = game.Players.LocalPlayer
local PlayerScripts = player.PlayerScripts
local PlayerModule = require(PlayerScripts.PlayerModule)
local controller = PlayerModule:GetControls()
controller.moveFunction = function() end
you can still get the move vector
print(controller:GetMoveVector())
if you want to re-enable the default movement, you can just set
controller.moveFunction = game.Players.LocalPlayer.Move