Hello there!
How can i make a big projectile that the player shoots in the mouse direction and because of gravity it will go down slowly until it hits an object?
I tried using it with curves but it didnt work as i wanted it to.
How can i achieve this?
Any help whould be greatly appreciated!!!
You can use FastCast. But gun physics is easy to code once you understand the formulas and maths.
You can simply use a Step method on the server and use Suvat to calculate the next Position.
If you did mathematics mechanics then you know that Acceleration can be integrated to get Velocity and Velocity to Position.
local Projectile = {
Acceleration = Vector3.new(0,-workspace.Gravity,0) -- You can add gravity or even wind depending on your needs
Velocity = Vector3.new(100,0,0) -- Initial velocity of the projectile when fired (code this yourself)
Position = Vector3.new(0,10,0) -- Starting position of proj
}
function Stepped(runTime, deltaTime)
Projectile.Position += Projectile.Velocoty * deltaTime -- wrt Time
Projectile.Velocity += Projectile.Acceleration * deltaTime
-- You could even have change the acceleration to oush the projectile forward if it is a propelled projectile
Part.Position = Projectile.Position -- Anchord part
-- To get collisions you will need to raycast
end