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

FilteringEnabled and Projectiles. CFrame or Physics?

Asked by 6 years ago

I've had many problems in the past dealing with modders and exploiters. So, as of late, I've been using Filtering to make sure things are nice and clean at all times. Under normal circumstances, I'd be using Rays to make sure that things connect quickly, but I've found myself stumped when it comes to projectiles that, as the name suggests, have travel time.

Normally I'm content having a projectile be anchored and moving along using CFrame, but there seems to be something off about it. I can't help but feel there's a disconnect between the player and what they're shooting. Now I'm not exactly going for something matrix-like, but I do want all players to see the projectiles being fired at one another.

At the moment I'm using tools connect to the server through a RemoteEvent that creates the projectile, but are there any other ways I could go about this?

0
RocketPropulsion is way easy and faster ? Just a suggestion sorry if its not what you want. arshad145 392 — 6y
0
Any suggestion is better than none. I'll try it out, thank you RichardHoss 2 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

One problem you may be running into is problem talked about by this article: Fighting Lag. Specifically, this is the fact that there is time between the player pressing "fire" and the server knowing about it. You might try to fix this by making the projectile appear as a "Local" projectile, at least until the server creates it -- but you'll need to delete the local projectile when the server creates the correct one, and they are unlikely to be in the same place, which will cause a jump.

An improvement is that all projectiles will be animated by the client. The strategy is this:

  1. User presses "fire"
  2. A local projectile is created (and starts moving) and the server is notified that a projectile should be made.
  3. The server creates the projectile and notifies all clients of its existence. Possibly, the projectile is invisible.
  4. All clients can hide the projectile locally (if it isn't transparent)
  5. All clients should now create a projectile that follows the server's projectile (except the client who fired the projectile, who already has this)
  6. Use RunService to update the position of the projectile smoothly. Keep in mind that the server only updates the physics up to 30x/sec, whereas the RunService's Heartbeat can run up to 60x/sec. ie, don't just do "visibleProjectile.CFrame = serverProjectile.CFrame" -- use lerp, or - if you can - predict where it will go (which is better for users if they might dodge the projectiles -- it's better to see the projectile where it will be because that's where it'll be by the time their reaction gets back to the server). If the prediction is off, you'll have to animate it or teleport it to the correct position.
Ad

Answer this question