I was doing some physics work and i realised my standard humanoid roblox character physics will probably not work well with my goals - i opted for a custom character controller.

I started with a sphere and bodyvelocity in it, this worked, but i wanted to keep the normal robloxian look and so i tried to attach my character to it with alignposition and an attachment that hovers above the spheres position (because the sphere rotates).
Sad to say it was wonky as hell and bugged out and flinged me to the sun every time.

Next I tried capsule, with my character in it, which i am probably going to stick with, but i cant for the love of me figure out how i can simulate gravity while using linearvelocity?

VectorForces are terrible for me, calculating mass and getting insanely high non-stop acceleration ,i had to scrap them immediately. Anyone have any experience with both? Is there an open-source repro i could learn from?

The non-stop acceleration is due to lack of drag forces and adding one should do the trick. However I would put a disclaimer that I have found that this is not a perfect solution as there is one flaw at low fps (1-10 fps) where the character will fling during high speeds due to Roblox treating the vector force as constant throughout the frame (1/60 seconds, worse at low fps 1/20)

EgoMooses character controller uses a sphere to create sliding motion. I imagine a sphere would not be good for modelling a character going up stairs as it will not be able to smoothly.

2 Likes

Does your controller use VectorForces as well? How did you calculate drag and gravity for them?

Yep my controller uses vector forces. I used not only drag force but also friction force will allows the character to stop faster at low speeds (drag is proportional to velocity squared, velocity close to zero, drag close to zero). I do not calculate gravity the Roblox engine handles that by itself.

``````--Friction formula
--Exponential is there as at low speeds there is less friction, prevents oscilations or force overshoot
flatFrictionScalar = model:GetAttribute("FlatFriction")*(1.0-math.exp(-2*xzSpeed))

--Drag force formula, XZ speed is .AssemblyLinearVelocity without y component
local netDragForce = -unitXZ*(xzSpeed^2)*model:GetAttribute("XZDragFactorVSquared")
``````
1 Like

I’ll have a look at your character controller and see if i can implement it into my current codebase, it looks like what i specifically need, thanks.