#Projectiles physics problem

1 messages · Page 1 of 1 (latest)

iron rune
#

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
frosty arch
#

Oii

versed kite
#

the whole module script

#

and the usage of it

gilded palm
#

Hm whats wrong with it...

dusty ingot
#

Also I'm pretty sure using physical parts for a gun system is highly frowned opon

iron rune
#

First off, you go on this chat shitting on my code without any good advice and later u talk about using physical parts in my system, where the only things that use parts is debugging😭

#

For you information its "scripting-help", no "rate-code"crying

iron rune
#

Imma back home and send it

iron rune
# versed kite and the usage of it

The general purpose of this code is just to make working projectiles affected by gravitational influence (Projectile motion) at the beginning i was using simple lines of code in my step method


self.Velocity += self.Gravity * DeltaTime
self.Position += self.Velocity * DeltaTime

Where Velocity is a LookVector * speed factor and Gravity -workspace.gravity

But at one point i wanted to implement influence of an angle that i calculated from camera but i think its not important (The only thing you should know that it gives range between 70 and -70 on Y Axis). And that's where i ended up

#

Important fact is that this :Step() method is in my .HeartBeat RunService so everything is actually fine. The problem is with calculations i think, and how i handle them