Skip to content

Commit

Permalink
fix(NetworkRigidbody Components): Added missing OnTeleport overrides (#…
Browse files Browse the repository at this point in the history
…3788)

* Updated NetworkRigidbody Components for fix teleportation issues

fix teleportation issue

* Optimizes Usage of Physic.SyncTransform.
  • Loading branch information
MarcinZboralski committed Apr 8, 2024
1 parent ae28158 commit 0726126
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,20 @@ protected override void OnValidate()
Debug.LogWarning($"{name}'s NetworkRigidbody.target {target.name} is missing a Rigidbody", this);
}
}

protected override void OnTeleport(Vector3 destination)
{
base.OnTeleport(destination);

rb.position = transform.position;
}

protected override void OnTeleport(Vector3 destination, Quaternion rotation)
{
base.OnTeleport(destination, rotation);

rb.position = transform.position;
rb.rotation = transform.rotation;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,20 @@ protected override void OnValidate()
Debug.LogWarning($"{name}'s NetworkRigidbody2D.target {target.name} is missing a Rigidbody2D", this);
}
}

protected override void OnTeleport(Vector3 destination)
{
base.OnTeleport(destination);

rb.position = transform.position;
}

protected override void OnTeleport(Vector3 destination, Quaternion rotation)
{
base.OnTeleport(destination, rotation);

rb.position = transform.position;
rb.rotation = transform.rotation.eulerAngles.z;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,20 @@ protected override void OnValidate()
Debug.LogWarning($"{name}'s NetworkRigidbody.target {target.name} is missing a Rigidbody", this);
}
}

protected override void OnTeleport(Vector3 destination)
{
base.OnTeleport(destination);

rb.position = transform.position;
}

protected override void OnTeleport(Vector3 destination, Quaternion rotation)
{
base.OnTeleport(destination, rotation);

rb.position = transform.position;
rb.rotation = transform.rotation;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,20 @@ protected override void OnValidate()
Debug.LogWarning($"{name}'s NetworkRigidbody2D.target {target.name} is missing a Rigidbody2D", this);
}
}

protected override void OnTeleport(Vector3 destination)
{
base.OnTeleport(destination);

rb.position = transform.position;
}

protected override void OnTeleport(Vector3 destination, Quaternion rotation)
{
base.OnTeleport(destination, rotation);

rb.position = transform.position;
rb.rotation = transform.rotation.eulerAngles.z;
}
}
}

0 comments on commit 0726126

Please sign in to comment.