#Projectile Tracing System

1 messages · Page 1 of 1 (latest)

harsh fern
#

I got a projectile system thats decently advanced and i want to add a way for players to see where the projectile will go before they throw it.

Projectiles Module:
https://pastebin.com/wXaHSy9Q

I also have a table of stats for the projectiles, idk if thats useful so here:
https://pastebin.com/1JtLfpFj

eager tapir
#

You could create an arrow gui on the floor with the player's position, and at the time he is doing the ability make it visible and using tween service give it colors or change size

spring pasture
#

fast cast already exists, but this is good

blazing scarab
#

here is an example

#
local function GetPositionAtTime(t: number, origin: Vector3, initialVelocity: Vector3, acceleration: Vector3): Vector3
    local force = Vector3.new((acceleration.X * t^2) / 2,(acceleration.Y * t^2) / 2, (acceleration.Z * t^2) / 2)
    return origin + (initialVelocity * t) + force
end

function Module.ShowExpectedTrajectory(Acceleration, Velocity, Dir)
    -- Get the player and their character
    local player = game.Players.LocalPlayer
    local character = player.Character or player.CharacterAdded:Wait()
    local mouse = player:GetMouse()

    local characterPos = character:WaitForChild("HumanoidRootPart").Position
    local mousePos = mouse.Hit.Position  -- Get the point in the world where the mouse is pointing

    -- Calculate the direction (unit vector) from the character to the mouse
    local direction = Dir or (mousePos - characterPos).unit
    Velocity = direction * Velocity
    
    
    for i = 1, 30, 1 do
        local Position = GetPositionAtTime(i/10, characterPos, Velocity, Acceleration)
        local Part = nil
        local Interval = # workspace.TrajectoryPartsFolder:GetChildren()
        if Interval > 29 then --Change this when you change the density of parts
            Part = workspace.TrajectoryPartsFolder["Part"..i]
        end
        if not Part then 
            Part = Instance.new("Part")
            Part.Name = "Part"..i
            Part.Parent = workspace.TrajectoryPartsFolder
            Part.Position = Position
            Part.Size = Vector3.new(1,1,1)
            Part.CanCollide = false
            Part.Anchored = true
            Part.Color = Color3.fromRGB(255, 255, 255)
            Part.Material = Enum.Material.Neon
        else
            Part.Position = Position
        end
        
    end
    -- Clean up trajectory points after the flight time
end```
#

I used fastcast function to calculate the projecilte's position

#

and yes I used chatgpt to get the direction from my mouse hit position and my character

#

as for the rest tho its all mine

harsh fern
#

alright thanks

harsh fern
harsh fern
#

oh yes they are

blazing scarab
#

For example acceleration is used for adding gravity and what

#

not

harsh fern
#

yeah i figured it out

#

thank you