I've tried to make my own projectile module but after aplying those calculations debug shows that position never changes. It just stays in place and position seems to never change
function ProjectilesHandler:Step(DeltaTime: number)
local function Debug(Switch: boolean)
if Switch then
local Part = Instance.new("Part")
Part.Name = "Debug"
Part.Size = Vector3.new(.5, .5, .5)
Part.CFrame = self.CFrame
Part.BrickColor = BrickColor.Red()
Part.Anchored = true
Part.CanCollide = false
Part.CastShadow = false
Part.Transparency = 0.5
Part.Parent = workspace
DebrisService:AddItem(Part, 0.5)
else
return
end
end
local Time = tick() - self.StartTime
self.Time += DeltaTime
Debug(self.Debug)
--x = v₀ cos(θ) * t
--y = v₀ sin(θ) * t - ½gt²
local X = self.Velocity * math.cos(self.Angle) * self.Time
local Y = self.Velocity * math.sin(self.Angle) * self.Time - ((.5*self.Gravity)*DeltaTime^2)
self.CFrame = CFrame.new(self.Origin.Position + Vector3.new(X, Y, 0))
if Time >= self.TimeDuration then
print("Cleaned up")
self:Cleanup()
return
end
end
