How can I make a projectile like this?

I want to create a projectile system with specific elements that I can also use for different weapons in my game. It’s primarily for a bomb in my game, but I figured that how the system works can also work for superballs, and maybe even slingshots or paintball guns if I make it so the projectiles aren’t affected by gravity and don’t arc. I’m not asking anyone to make any scripts for me, but I’m not exactly sure where to start with this or what I should be using in the first place to help me achieve this.

What I want:

  • An arc that dictates the path of the projectile, ranging from the player to the player’s mouse position.

    • The angle of the arc to be tweakable.
    • The arc will be visible to players and each section will be separated by individual lines instead of just one long line.
  • When the mouse is released, the projectile is released.

  • When released, the projectile follows the path of the arc, though this will be physics-based rather than through tweens or similar methods.

And that’s pretty much it.

But I’m stumped on how I should

  • Make a physics-based system that dictates where the projectile will go along with the arc.
  • Make a visual arc that follows the range of the arc that the projectile will go in.

So, what should I do?

1 Like
  • First you should get the position of the mouse in the 3D space on client using Player:GetMouse().Hit.Position
  • Use a remote event to send over that position
  • Get the direction on the server.
    (MousePos - plr.Character.PrimaryPart.Position).unit
  • Clone the projectile and spawn it where ever you it to be thrown from.
  • Get the distance between the mouse position and the projectile.
    (projectile.Position - MousePos).Magnitude
  • Change the direction variable so we can calculate the arc shape.
direction = (MousePos - projectile.Position).Unit
direction = Vector3.new(direction .X, 0, direction .Z)
  • Calculate the velocity for the arc.
velocity = math.sqrt(distance * workspace.Gravity) * (direction + Vector3.new(0,0.5,0)).Unit
  • Lastly give the projectile that velocity.
    projectile.AssemblyLinearVelocity = velocity
3 Likes

Forgot to ask, but could you explain the formula for the velocity and how it works?

math.sqrt gets the square root of the number, so it’s the square root of the distance x gravity (of the workspace), then you times it by the unit of the direction to get the velocity for the projectile then you set it

Well, I understand that but I’m asking how this formula translates to an arc and how doing things such as multiplying the distance and gravity, using sqrt on that, and adding the direction to an offset makes the velocity work.

I don’t know if I’m missing something, but I know I should’ve probably clarified that.

theres tutorial series for this (you dont have to do the bouncing projectile one)

The Most ACCURATE Projectile in ROBLOX!! (youtube.com)
The Most ACCURATE BOUNCING Projectiles in ROBLOX!!! (youtube.com)
CLIENT REPLICATION for our ROBLOX Projectile using the NEW UnreliableRemoteEvent!!! (youtube.com)