Skip to content

Commit

Permalink
Update NetworkTransformBase.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
miwarnec authored Dec 30, 2024
1 parent 2508cfd commit 53d78e8
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions Assets/Mirror/Components/NetworkTransform/NetworkTransformBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,10 @@ public uint sendIntervalMultiplier
protected double timeStampAdjustment => NetworkServer.sendInterval * (sendIntervalMultiplier - 1);
protected double offset => timelineOffset ? NetworkServer.sendInterval * sendIntervalMultiplier : 0;

[Header("Velocity")]
[ReadOnly, SerializeField] Vector3 _velocity;
[ReadOnly, SerializeField] Vector3 _angVelocity;

public Vector3 velocity
{
get => _velocity;
internal set => _velocity = value;
}

public Vector3 angVelocity

{
get => _angVelocity;
internal set => _angVelocity = value;
}
// velocity for covenience (animators etc.)
// this isn't technically NetworkTransforms job, but it's needed by so many projects that we just provide it anyway.
public Vector3 velocity { get; private set; }
public Vector3 angularVelocity { get; private set; }

// debugging ///////////////////////////////////////////////////////////
[Header("Debug")]
Expand Down Expand Up @@ -280,12 +268,12 @@ protected virtual void Apply(TransformSnapshot interpolated, TransformSnapshot e
// -> but simply don't apply it. if the user doesn't want to sync
// scale, then we should not touch scale etc.

// Calculate the velocity and angular velocity for the object
// These can be used to drive animations or other behaviours
if (!isOwned)
// calculate the velocity and angular velocity for the object
// these can be used to drive animations or other behaviours
if (!isOwned && Time.deltaTime > 0)
{
velocity = (transform.position - interpolated.position) / Time.deltaTime;
angVelocity = (transform.rotation.eulerAngles - interpolated.rotation.eulerAngles) / Time.deltaTime;
angularVelocity = (transform.rotation.eulerAngles - interpolated.rotation.eulerAngles) / Time.deltaTime;
}

// interpolate parts
Expand Down

0 comments on commit 53d78e8

Please sign in to comment.