I am currently trying to make a system (for roblox) that is basically just a Vector3 that has physics and collision, it doesn't have volume it's literally just a vector position in 3d space. I've made a small amount of progress but I don't really know what the best way of going at making this is.
This is what it looks like when I run the simulation and let the coins fall. (Ignore the static coin in the center) Picture of visualization
These coins are just a sprite that I put on top of the Position of the orb. So the position of the coin is at the very bottom of the coin (at the floor).
I made a visualization too, so every arrow you see is a different raycast that checks for interference/collision.
The problem:
If you watch this little clip, you can see the problem instantly. My coin is shaking when it is in a place like this. I think this has to do with the bounce code I made. https://gyazo.com/38b1903b33d8f7e4ab5b477acdd5f1d2
How would I make it so that my coin only bounces a couple of times and then stops, while still behaving like it should iykwim.
This is my current code in the step function (called every frame).
if (self.Anchored) then return end
self.LastPosition = self.Position
self.Velocity += self.Gravity * DT
self.Position += self.Velocity * DT
local Result: RaycastResult? = self:_raycast(self.LastPosition, self.Position)
if (Result) then
self.Position = Result.Position
self.Velocity = ReflectNormal(Direction, Result.Normal) * (self.Velocity.Magnitude * self.BounceMultiplier)
end
I expect my coin to not start shaking when it gets "stuck" like that. It should only move when it has too.