Compare commits

...

3 Commits

Author SHA1 Message Date
MrGadget
d825caab67
Merge 2508cfd618 into 1e04c9833b 2024-11-11 13:38:54 +01:00
JesusLuvsYooh
1e04c9833b
Updated Server/Client attribute help text. (#3942)
Some checks are pending
Main / Run Unity Tests (push) Waiting to run
Main / Semantic Release (push) Blocked by required conditions
Main / Delete Old Workflow Runs (push) Waiting to run
Hopefully adds additional support in preventing confusion.
2024-11-11 13:06:29 +01:00
MrGadget
2508cfd618 feat(NetworkTranformBase): Provide velocity and angular velocity 2024-09-30 08:41:02 -04:00
2 changed files with 31 additions and 6 deletions

View File

@ -119,6 +119,23 @@ public uint sendIntervalMultiplier
protected double timeStampAdjustment => NetworkServer.sendInterval * (sendIntervalMultiplier - 1); protected double timeStampAdjustment => NetworkServer.sendInterval * (sendIntervalMultiplier - 1);
protected double offset => timelineOffset ? NetworkServer.sendInterval * sendIntervalMultiplier : 0; 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;
}
// debugging /////////////////////////////////////////////////////////// // debugging ///////////////////////////////////////////////////////////
[Header("Debug")] [Header("Debug")]
public bool showGizmos; public bool showGizmos;
@ -263,6 +280,14 @@ protected virtual void Apply(TransformSnapshot interpolated, TransformSnapshot e
// -> but simply don't apply it. if the user doesn't want to sync // -> but simply don't apply it. if the user doesn't want to sync
// scale, then we should not touch scale etc. // 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)
{
velocity = (transform.position - interpolated.position) / Time.deltaTime;
angVelocity = (transform.rotation.eulerAngles - interpolated.rotation.eulerAngles) / Time.deltaTime;
}
// interpolate parts // interpolate parts
if (syncPosition) SetPosition(interpolatePosition ? interpolated.position : endGoal.position); if (syncPosition) SetPosition(interpolatePosition ? interpolated.position : endGoal.position);
if (syncRotation) SetRotation(interpolateRotation ? interpolated.rotation : endGoal.rotation); if (syncRotation) SetRotation(interpolateRotation ? interpolated.rotation : endGoal.rotation);

View File

@ -48,28 +48,28 @@ public class TargetRpcAttribute : Attribute
} }
/// <summary> /// <summary>
/// Prevents clients from running this method. /// Only an active server will run this method.
/// <para>Prints a warning if a client tries to execute this method.</para> /// <para>Prints a warning if a client or in-active server tries to execute this method.</para>
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public class ServerAttribute : Attribute {} public class ServerAttribute : Attribute {}
/// <summary> /// <summary>
/// Prevents clients from running this method. /// Only an active server will run this method.
/// <para>No warning is thrown.</para> /// <para>No warning is thrown.</para>
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public class ServerCallbackAttribute : Attribute {} public class ServerCallbackAttribute : Attribute {}
/// <summary> /// <summary>
/// Prevents the server from running this method. /// Only an active client will run this method.
/// <para>Prints a warning if the server tries to execute this method.</para> /// <para>Prints a warning if the server or in-active client tries to execute this method.</para>
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public class ClientAttribute : Attribute {} public class ClientAttribute : Attribute {}
/// <summary> /// <summary>
/// Prevents the server from running this method. /// Only an active client will run this method.
/// <para>No warning is printed.</para> /// <para>No warning is printed.</para>
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]