Hey there again fellow Roblox Developers, I am here again trying to solve another problem I can’t wrap my head around, so why not use someone elses head… so straight to it.
I’ve made progress towards my gliding mechanics, and I was able to apply gravity, momentum etc etc…
but I wanted to add something a little extra to the player’s character… a CAPE
x.com… Voila, this guy has done it beautifully, so I decided to do some research and I came across Verlet Integration by EgoMoose, and I was able to follow along and understand at least %40 of what’s being explained and all in all I was able to make my classes with their corresponding methods
Constraint Class
local c = {}
c.new = function(p1, p2, d)
local self = setmetatable({}, {__index = c})
self.point1 = p1
self.point2 = p2
self.restDist = d
self.canBreak = false
self.breakDistance = 5
self.line = Instance.new("Part")
self.line.Size = Vector3.new()
self.line.Anchored = true
self.line.CanCollide = false
self.line.BrickColor = BrickColor.new("Really black")
self.mesh = Instance.new("BlockMesh", self.line)
self.mesh.Scale = Vector3.new(0.2, 0.2, 0.2)
return self
end
function c:solve()
if self.point1 and self.point2 then
local difference = (self.point1.Position - self.point2.Position)
local distance = difference.magnitude
local scalar = (self.restDist - distance) / distance
local translation = difference * 0.5 / scalar
if not self.point1.anchored then
self.point1.position = self.point1.position + translation
end
if not self.point2.anchored then
self.point2.position = self.point2.position - translation
end
if self.canBreak and (self.point1.position - self.point2.position).magnitude > self.restDist + self.breakDistance then
self:Destroy()
end
end
end
return c
Point Class
local Point = {}
local Gravity = workspace.Gravity
Point.new = function(V3)
local self = setmetatable({}, {__index = Point})
self.Position = V3
self.PriorPosition = V3
self.Velocity = Vector3.new()
self.Acceleration = Vector3.new()
self.Anchored = false
return self
end
function Point:Update(dt, damp)
if not self.Anchored then
self.Acceleration = Vector3.new(0, -Gravity, 0)
self.Velocity = self.Position - self.PriorPosition
self.PriorPosition = self.Position
self.Position = self.Position + (self.Position - self.PriorPosition) + self.Acceleration * dt^2
else
self.Velocity = Vector3.new()
self.Acceleration = Vector3.new()
self.PriorPosition = Vector3.new()
end
end
return Point```
but my problem is, I have no clue how to apply this in the way that I'd be able to have collision and cape physics.
TL:DR Im trying to make a cape and I used EgoMooses formulas but Idk how to apply them to get the cape going, please help if you can thank you!