How do I make tank projectiles?

Hello, I’m trying to make a tank game, currently I want to make the tank shoot shells when the player clicks a button on their keyboard (something like Space). I’ve never worked with projectiles before, so I wanted to ask, what’s best to use in this situation (Tweening, BodyVelocity etc.), and maybe some code examples on it? Here’s a video of what I’ve got so far: https://gyazo.com/83f048b8f6ae5ff908bc16ef9e3bb454

3 Likes

You have a few choices for this: first of all, you could make a shell in the serverstorage and clone it to the barrel of the tank and then give it a bodyvelocity fore example. You could also just use Instance.New() to make a new shell inside the script, but in my opinion that’s a bit harder. I also suggest scavenging the depths of google and youtube.

2 Likes

Okay, thank you, I’ll try my best :stuck_out_tongue:

1 Like

BodyVelocity requires shuffling network ownership in order to not appear laggy from the player’s side, I’d suggest using FastCast if you could get around to it


(I’m willing to open source the game shown in the video if you need it)

If you manage network replication property you can have secure and very nice-looking bullets with stuff such as ricochets or wall penetration

the actual details is just firing an invisible shot with the server for hit registration and telling clients to replicate it with a RemoteEvent, something which doesn’t really work because of physics inconsistencies with physics based methods

You could also just use hitscan for hitreg and add tracer projectile effects, some games tend to do this for the sake of simplicity

10 Likes

Sorry for late reply
I’ve seen fastcast before, but I’ve been told by someone that it’s not great? Though it looks fine in the video (game looks amazing, by the way :stuck_out_tongue:). Open sourcing sounds great to be honest, I’m not that experienced at scripting yet, I have a feeling I wouldn’t figure it out on my own, so it would be very helpful.

1 Like

FastCast is great, It is actually the best thing you could use probably, and using It is faster and easier than developing your own module. Open Sourcing is amazing, and you should take advantage of that.

Obviously don’t start to insert any freemodel and open source thing in your game, make sure that It is a good module before doing It.

1 Like

FastCast isn’t that great. It fails miserably at close range combat (not drawing any rays or projectiles, despite still shooting with an invisible bullet) and falls off when you start to mess with it a little. The projectiles in the default module also tend to completely ignore characters and shoot through them, or hit them and not do any damage, just create a hit effect.

It’s a good module, but definitely not a “one size fits all” type of solution.

1 Like

Im kinda confused so are you using body movers or raycasting to the next position every time the bullet travels?

And for the projectiles are you sending data to every client to caluclate themselves or replicating the projectiles by sending the position of the bullets to the clients every x amount of frames, and making the client tween the bullet to that position

again, I use fastcast, which you should check for how the bullets work in the background
the shooter tells the server to replicate the shot and do damage, and the server tells all other clients to fire the shot with the same parameters as the shooter did

Oh this is what I used to do, until I fount some incosnsites, with the server bullets. And yes my server bullets just raycasted they didn’t have models, they were the ones doing damage.

It wasn’t the client bullet reaching the destination further which was the problem I already had compesation for that, it was when you moved the server bullets would be offsetted the opposite direction you moved a little.

That probably just means you screwed up the code a bit. My projectiles work pretty much flawlessly (hitreg without anything obstructing the target hits 100% of the time, and ricochets/wallbangs are still secure and cannot be exploited to my knowledge)

The difference isn’t really big it’s one two to studs but it can be problamtic sometimes, im not sure I just send the original shooting info to the server and all the clients except the shooter

Im pretty sure I might need more lag compesation, what way do you use for lag compesation.

hey blackshibe,

i know it’s a long time you posted this solution but are you still willing to open-source the game from the video you provided?

1 Like