Throwable Projectiles - Recommendations appreciated

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want to achieve throwable projectiles with an arc, just for an example say a snowball, that are 1. Secure and harder to exploit 2. It’s a project I want to work on partly for learning experience, and for a game possibly, so I am not particularly asking for code handout although if you already have a coded example I am also not opposed to learning from it, while it’s not what I am asking for. edit: 3. I also ideally want it to actually look like the object is say being thrown out of my hand, or the tool it’s in and not like spawning already flying in the direction, although I think I have an idea of how I would do that, I don’t really know the best way.

  2. What is the issue? I have been looking into way’s to do it, but I want to hear what you guys have recommended & OR have used personally.

  3. What solutions have you tried so far? I have been experimenting with BodyVelocity(Don’t really want to use that, considering it seems easily exploitable), I also most recently was looking it RayCasting, & FastCast

23 Likes

I was thinking of doing the same thing a while back, and one way I came up with is having the clients run the visual side of the particle locally, and let the server take care of the actual position and detecting the hit.

For example, when a player throws a snowball, they create a new instance of the snowball locally and make it land somewhere. Then, they fire an event to the server, which tells all the other players to show the snowball flying out of the player who threw it. Then, the server calculates the position on its side, and when it detects that the snowball hit a player, it will remove some of their health and tell all players to delete the snowball model and play the hit effects (sounds, particles, etc.)

Also just a small tip, if you want the player feel the impact of the attack, add a hit marker or something to indicate that they successfully hit someone. That way, there won’t be an awkward pause while waiting for the server to confirm if your snowball landed on someone.

12 Likes

Thank you! How would you recommend/did you handle the physics of it? RayCasting?

8 Likes

Yeah something like that, maybe make your own mini-physics calculations since Roblox’s physics relies on client hardware for that, basically allowing exploiters to do whatever they want with unanchored parts, but that’s only useful if the environment is dynamic, like gravity and such.

9 Likes

I had also seen impulses but that seems very client side, I want to really make sure EVERYBODY sees the same thing and it’s not like I HIT YOU, or YOU DIDN’T HIT ME that MISSED yk? Do you know what most modern games use?

5 Likes

Then for that I think you can use an anchored part on the server that is visible to all players and make it move there, but there will be some lag with that.

8 Likes

So I guess the best thing is just do what the server sees? In terms of minimizing lag? Should I just use fastcast or a custom system? FastCast does seem somewhat outdated so I am not sure if there is a better way.

8 Likes

If there’s nothing that can affect the projectile’s velocity, then fastcast is a good option, but if there are things like launch pads or gravity changes then a small custom physics script could handle it easily. I’m sure it wouldn’t be too hard to make one either way.

5 Likes

Any recommendations of documentation to look into or what I might use to do it? I probably will do the latter for the customization.

4 Likes

Would impulses work well? I see somebody else is using that

4 Likes

Not really sure, but I heard something about Arsenal having some sort of gun that shoots projectiles by showing the model on the client and letting the server detect hits. Also I think TF2 and Quake have similar mechanics as well.

4 Likes

Impulses rely on Roblox’s own physics scripts, so I don’t think so. You just have to give the projectile a set velocity and then moving it from there.

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.