Raycasts aren’t accurate if the player is moving (CLIENT SIDED RAYCASTS)

I put caps to highlight the text, not to make it sound M E A N

1 Like

Show me where have i mentione network ownership and baseparts?

I spoke about replication.
that the thing you were talking about, innit?

You can use italics or bold to highlight your text.

Also, here you go:

1 Like

UPDATE: Im still trying to find a fix for this issue, ive come to the conlusion I may have to use a different method to detect hits

Are you calculating the hits on the client and sending it to the server (based on the title I would assume so, but just checking)

Yes, i create the raycasts on the client, the server takes care of the damge etc

Also for the direction of the raycast, take the look vector of the HumanoidRootPart and multiply it by a lot (100? I don’t know exactly)

wouldnt that just be the range? (if you’re multiplying the lookvector by a number)

local direction = ((player.Character.HumanoidRootPart.CFrame.LookVector * 100 ) * configs.Range)

maybe add it to the original postition vector3? Not really good with 2d games but this might be a solution

Because the issue is with the direction of the raycast, it is spawning on the HumanoidRootPart but not calculating the direction correctly

I was thinking the same thing, i just find it odd that when the player moves the OLD player position is taken into account but not the new look vector (there shouldnt even be delay considering this is on the client) but at least this is my theory i dont know if thats exactly whats happening since i adjusted player speed to be very slow and then moved, but the “lookvector” or where the bullet hit was very far from the player (meaning the gun never even reached that point)

do you know if theres a way to account for the character’s velocity? maybe that would help because it regards the players movement; if i can find a way to incorporate it into the equation it could fix the weird offset or angle that the raycast creates

You can use the primary parts LinearAssemblyVelocty

how would i implement it in the current direction/origin position?

I finally found the error/solution: im currently using a custom character for my game, now, when the character moves it appears smooth and linear on the client, HOWEVER, the movement is extremely jerky on the server, so when the raycasts were made i couldnt actually see that the main issue was not the math but rather the player movement