1.What I want to achieve
I want to make a custom character controller that can be rotated while still having the player move relative to its rotation
-
the issue … plenty of videos ahead
I’ve made this using a line force. The problem is that the character mover infinitely accelerates. I want the character mover to move at a consistent speed
Video example
- What solutions have I tried so far?
I have attempted multiple solutions. I’ll list these solutions and explain why I think i didn’t work
- I’ve tried using a drag force script from this post (How do I limit the velocity of VectorForce? - #20 by dthecoolest) and I changed the script to fit the context of my script, but now the drag force infinitely accelerates
video example
Current version of the drag force script
while true do
task.wait()
local velocity = script.Parent.AssemblyLinearVelocity
local speed = velocity.Magnitude
local XZVector = 1
script.Parent.PlrMoveTargetPart.Position = script.Parent.PlrMovementAttach.CamLookAwayAttach.SingleAxisRotate.MoveAtchParent.MoveGoal.WorldPosition
--the drag force section
if speed > 0.1 then
script.Parent.DragForce.Magnitude = -(speed^2)
print(speed)
else
script.Parent.DragForce.Magnitude = 0
end
end
additional screenshot:
- I previously used a different version of the script that used vector forces, and it worked perfectly fine until I rotated the player to move upwards. It would then infinitely accelerate upward
video example of it going upwards
-
- I used the drag force script on this, and fixed the issue, but now the character mover glides down to the ground instead of falling like a normal physics object
video of it falling down slowly instead of falling down fast/normally as well as a bug I found
the drag force on the normal mover might not work if device is really laggy
I can fly when I apply drag force on every axis (specifically the Y axis), but I still glide down after a jump
The script for this version:
dragForce.Attachment0 = script.Parent.PlrMovementAttach
dragForce.Force = Vector3.new()
dragForce.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
dragForce.Parent = script.Parent
dragForce.Name = "DragForce"
while true do
task.wait()
local velocity = script.Parent.AssemblyLinearVelocity
local speed = velocity.Magnitude
local XZVector = Vector3.new(1,1,1)
script.Parent.MoveForce.Force = script.Parent.PlrMovementAttach.CamLookAwayAttach.SingleAxisRotate.LookerAttach.WorldCFrame.LookVector*10000
script.Parent.PlrMoveTargetPart.Position = script.Parent.PlrMovementAttach.CamLookAwayAttach.SingleAxisRotate.MovingAttachment.MoveGoal.WorldPosition
--the drag force section
if speed > 0.1 then
dragForce.Force = -velocity.Unit*(speed^2)*XZVector
else
dragForce.Force = Vector3.new()
end
print(speed)
end
additional screenshot:
- I’ve tried to use linear velocity with the LineForce constraint mode, but it wouldn’t rotate when I moved the camera (I have a script that rotates an attachment in the mover based on where the camera is looking).
- I’ve tried adding a max force limit to the line force, but that still allowed the mover to accelerate infinitely, just at a slower pace
- I once tried making the force be applied in an “equal” way rather than an “additive” way (example: I did
speed = 25
instead ofspeed += 25
) but that just made the part fall down slowly
I have no idea how to solve this. What can I do?