Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i shoot multiple projectiles simultaneously?

Asked by 5 years ago
Edited 5 years ago

Hello! Thank you for reading this.

I've recently struck an iceberg when trying to develop my game, I've made a shotgun in this game that is supposed to shoot, Well, Like a shotgun. The only problem is that the bullets are very, very out of sync. I want the bullets to be actual objects (small cubes for the time being) whom's velocity control the bullet itself. Is there a better approach for this? Is there any other type of projectile i could use that isn't a physical object.

I've played lots and lots of the game Phantom forces (which is in Roblox) and their bullets look somewhat like lasers and don't seem to be controlled by any physical objects.

I can try to explain how the scripts in my game work: the bullets work by sending a signal from a localscript (that detects if the player is clicking) trough a remoteEvent were a Server side script spawns the bullets.

I've tried lots of solutions but none work, That is if no-one answers this question.

0
Well try to not add wait() in your code. You're probably looping through something with a long distinguishable wait time BlackOrange3343 2676 — 5y
0
I talked to daxter33 about this (the creator of paintball) and he told me that he only used an object so a player could see how they died. What he actually did to detect hits was creating a variable that simulated the worldspace of the bullet and checked if there was a hit every time he moved it. He also told me that you'd have to understand physics to do that equation though lol. cmgtotalyawesome 1418 — 5y
0
try using rays Clasterboy 72 — 5y
0
I've done shotguns before, I used a "for" loop and made all of the bullets go in random directions. Mr_Unlucky 1085 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

Phantom Forces uses raycasting rather than physical projectiles. Raycasting basically gets two vectors and draws a line between the two. If something is in the way of that line, it returns information about what it hit.

If you are new to this, I recommend reading up on these: https://developer.roblox.com/articles/Raycasting https://developer.roblox.com/articles/Making-a-ray-casting-laser-gun-in-Roblox

Once you get a good feeling about how raycasting works, EtiTheSpirit created a module that does projectile raycasting. What it does is shoots a raycast in multiple segments to get towards the endpoint, creating that bullet travel effect. https://devforum.roblox.com/t/making-a-combat-game-with-ranged-weapons-fastcast-may-be-the-module-for-you/133474

If you don't feel comfortable with this, you can always just make it seem like the bullet is traveling. with part manipulation.

To create a shotgun, you would get the mouse position and add a spread to it. The spread will offset your mouse position randomly making the bullet not exactly on target. If you make it a function, you can use a for loop to run it multiple times. This will make it shoot x amount of bullets each of them having a random spread.

0
Thanks for the answer! I knew that raycasts would probably work but i wasn't bothered to look into it. Vinceberget 1420 — 5y
Ad

Answer this question