I have Gameobjects (projectiles) that are instantiated from clients. These projectiles have not too much speed:
transform.Translate(Vector3.forward * Time.deltaTime * 15);
Each projectile has a photon view that keeps track of the current position and rotation with the following code:
transform.position = Vector3.Lerp(transform.position, realPosition, Time.deltaTime * 5);
transform.rotation = Quaternion.Lerp(transform.rotation, realRotation, Time.deltaTime * 5);
My problem however is, each projectile has a OnCollisionEnter method which works fine, but the visuals aren’t really well. On the client that has spawned the projectile, the projectile actually hits the other player, but for the other player the collision will trigger a lot before it actually hits which results in the other player thinking “Hey that didn’t hit me!”.
I assume this is because I’m not keeping track of the real position every frame, but how can I get closer to the real collision position without making the movement really jittery/laggy? How is this achieved in other games?
Thanks in advance!