so this is a continuation to my previous .Touched post. turns out the event itself works fine, but for some reason the bombs position on the client is different than on the server.
here is my script:
and here are some pics of the bug itself:
Teleport it to itself on the server.
yeah i did that and its better because it appears at the right position but it also makes it look kinda choppy
Looks like it may be latency related. Is the bomb being manipulated on the client at all?
nope the bomb is created on the server and manipulated on the server
Taking a shot in the dark here, but try setting the networkownership to the player who threw it for now just to see what happens.
ive tried it before and it simply didnt move, but ill try again.
yeah they just dont move. do i have to do the velocity part on the client?
Honestly this seems more and more like one of those weird limitations with the physics engine in regards to replication. Are you using
:ApplyImpulse() as your method for adding velocity?
yeah i am. should i use something else?
Okay, so a funny caveat with using
ApplyImpulse is that only the physics owner can use that function. Because of this if you do decide to keep it as networkowned by the player, it needs to have it’s force applied by the client.
Also from prior experience, using ApplyImpulse on server operated physics objects can result in very inconsistent motion.
Edit: Either try manually setting the physics to the server to use applyimpulse, or you can try it on the client which will return smoother results(potentially better overall), but can be exploitable.
i did this instead:
and now the stuttering is gone, but the bombs end up levitating both on the client and on the server. any ideas on what i could do in this case?
edit: nvm it works
edit 2: nvm it does not
The issue with levitation is likely due to touched being fired early. Perhaps try a different collision detection method? When it comes to relying on Touched for critical game functionality, I’d advise against it for a number of factors.
Two possible ways I can suggest is manually moving thrown objects through stepped raycasts, or alternatively try to pick up touched objects using spatial queries.
Edit: Alternatively you could try and fire a raycast of some sort after touched is fired to find a surface to attach to.
nevermind it works fine. the bombs are flying smooth and the touched event works just fine (maybe a lil bit laggy). i simply forgot to remove this old line of code
edit: nevermind, turns out the bomb appears in the right position for the client, but not on the server.