Is it possible to change how the player moves?

Hey! Good morning, evening and so on!
I have a question and I’m not sure if it’s possible to do.
Is it possible to change the movement of the player? I want to simulate like a tank movement, use W for going forward, S to backward but not changing the orientation of the player and A D to rotate the character orientation.
If it’s possible ill appreciate any help.
Thanks! :slight_smile:

3 Likes

They just released this Announcement 9 days ago. It may help you out:

2 Likes

Well I would personally not change the character movement for the character if your trying to make a tank game. All I would do is to get a Model for your tank add controls for it using velocity or something(don’t quote me on this) and put a camera that updates connected to the tank and boom no hard scripting with the character. If you do need to change the character to move like you said I would look into the person with a comment above me.

1 Like

yeah i want to do something like this but without using the vehicle seat… so it’s kinda complicate.

1 Like

You shouldn’t need a veichal seat I think

You can do this, but it would require forking the control module.

I think it’s the fastest way to make a vehicle works, but im trying to make an arcade movement with a sphere collision so I dont want to use the vehicle seat

what u mean? I’m tryint to make my own because of i want it to be arcade, not so realistic

There’s no way for you to alter player movement without forking the Control module located under StarterPlayerScripts.PlayerModule.

yeah I found this part of code:

function Keyboard:BindContextActions()

-- Note: In the previous version of this code, the movement values were not zeroed-out on UserInputState. Cancel, now they are,
-- which fixes them from getting stuck on.
-- We return ContextActionResult.Pass here for legacy reasons.
-- Many games rely on gameProcessedEvent being false on UserInputService.InputBegan for these control actions.
local handleMoveForward = function(actionName, inputState, inputObject)
	self.forwardValue = (inputState == Enum.UserInputState.Begin) and -1 or 0
	self:UpdateMovement(inputState)
	return Enum.ContextActionResult.Pass
end

local handleMoveBackward = function(actionName, inputState, inputObject)
	self.backwardValue = (inputState == Enum.UserInputState.Begin) and 1 or 0
	self:UpdateMovement(inputState)
	return Enum.ContextActionResult.Pass
end

local handleMoveLeft = function(actionName, inputState, inputObject)
	self.leftValue = (inputState == Enum.UserInputState.Begin) and -1 or 0
	self:UpdateMovement(inputState)
	return Enum.ContextActionResult.Pass
end

local handleMoveRight = function(actionName, inputState, inputObject)
	self.rightValue = (inputState == Enum.UserInputState.Begin) and 1 or 0
	self:UpdateMovement(inputState)
	return Enum.ContextActionResult.Pass
end

local handleJumpAction = function(actionName, inputState, inputObject)
	self.jumpRequested = self.jumpEnabled and (inputState == Enum.UserInputState.Begin)
	self:UpdateJump()
	return Enum.ContextActionResult.Pass
end

-- TODO: Revert to KeyCode bindings so that in the future the abstraction layer from actual keys to
-- movement direction is done in Lua
ContextActionService:BindActionAtPriority("moveForwardAction", handleMoveForward, false,
	self.CONTROL_ACTION_PRIORITY, Enum.PlayerActions.CharacterForward)
ContextActionService:BindActionAtPriority("moveBackwardAction", handleMoveBackward, false,
	self.CONTROL_ACTION_PRIORITY, Enum.PlayerActions.CharacterBackward)
ContextActionService:BindActionAtPriority("moveLeftAction", handleMoveLeft, false,
	self.CONTROL_ACTION_PRIORITY, Enum.PlayerActions.CharacterLeft)
ContextActionService:BindActionAtPriority("moveRightAction", handleMoveRight, false,
	self.CONTROL_ACTION_PRIORITY, Enum.PlayerActions.CharacterRight)
ContextActionService:BindActionAtPriority("jumpAction", handleJumpAction, false,
	self.CONTROL_ACTION_PRIORITY, Enum.PlayerActions.CharacterJump)

end

So I think i need to change how it works here

1 Like

Forking the control module isn’t the best choice and definitely not the most efficient one.
You can easily toggle the ability to rotate with the Humanoid.AutoRotate property. Then, you can use CFrame.Angles to rotate the character manually, possibly inside a RunService.PreRender event.

But i think this is not a good option of what im trying to do, I just want to rotate the player with the tank when he press A or D, and for S i just want that the player don’t turn around and look backwards.

An easy way out would be to create a dummy and change its appearance to the player with
Players:GetHumanoidDescriptionFromUserId()
and apply it.
Then use the UserInputService to control and change the camera to focus on the dummy.

What i did to fix this and create the custom movement was to bind keys with special functionality using the ContextActionService:BindAction

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.