Added UI to Furnance, fixed carry and drag obj and added fish
This commit is contained in:
@@ -14,6 +14,12 @@ public abstract class NetworkHeldInteractable : NetworkInteractable
|
||||
[SerializeField] private Collider[] objectColliders;
|
||||
[SerializeField, Min(0.05f)] private float collisionRefreshInterval = 0.25f;
|
||||
|
||||
[Header("Holding Follow")]
|
||||
[SerializeField, Min(0.01f)] private float positionSmoothTime = 0.12f;
|
||||
[SerializeField, Min(0.1f)] private float maximumFollowSpeed = 12f;
|
||||
[SerializeField, Min(0.1f)] private float maximumFollowDistance = 1.25f;
|
||||
[SerializeField, Min(0.1f)] private float rotationFollowSpeed = 14f;
|
||||
|
||||
[Header("Throw")]
|
||||
[SerializeField, Min(0f)] private float throwForce = 6f;
|
||||
[SerializeField, Min(0f)] private float throwUpwardForce = 0.5f;
|
||||
@@ -25,6 +31,9 @@ public abstract class NetworkHeldInteractable : NetworkInteractable
|
||||
|
||||
private readonly HashSet<Collider> ignoredPlayerColliders = new();
|
||||
private float nextCollisionRefreshTime;
|
||||
private Vector3 followVelocity;
|
||||
private Vector3 previousHolderPosition;
|
||||
private bool hasPreviousHolderPosition;
|
||||
|
||||
protected abstract Vector3 HoldingOffset { get; }
|
||||
protected abstract string DropPrompt { get; }
|
||||
@@ -79,10 +88,9 @@ public abstract class NetworkHeldInteractable : NetworkInteractable
|
||||
return;
|
||||
}
|
||||
|
||||
FollowHolderTranslation(holder.transform.position);
|
||||
Transform anchor = ResolveHoldingAnchor(holder);
|
||||
transform.SetPositionAndRotation(
|
||||
anchor.TransformPoint(HoldingOffset),
|
||||
anchor.rotation);
|
||||
FollowHoldingAnchor(anchor);
|
||||
|
||||
if (Time.time >= nextCollisionRefreshTime)
|
||||
{
|
||||
@@ -175,16 +183,70 @@ public abstract class NetworkHeldInteractable : NetworkInteractable
|
||||
return cameraController != null ? cameraController.AimTransform : holder.transform;
|
||||
}
|
||||
|
||||
private void FollowHoldingAnchor(Transform anchor)
|
||||
{
|
||||
Vector3 targetPosition = anchor.TransformPoint(HoldingOffset);
|
||||
Vector3 targetDelta = targetPosition - transform.position;
|
||||
|
||||
if (targetDelta.sqrMagnitude > maximumFollowDistance * maximumFollowDistance)
|
||||
{
|
||||
transform.position = targetPosition -
|
||||
targetDelta.normalized * maximumFollowDistance;
|
||||
followVelocity = Vector3.zero;
|
||||
}
|
||||
|
||||
transform.position = Vector3.SmoothDamp(
|
||||
transform.position,
|
||||
targetPosition,
|
||||
ref followVelocity,
|
||||
positionSmoothTime,
|
||||
maximumFollowSpeed,
|
||||
Time.deltaTime);
|
||||
|
||||
float rotationBlend = 1f - Mathf.Exp(-rotationFollowSpeed * Time.deltaTime);
|
||||
transform.rotation = Quaternion.Slerp(
|
||||
transform.rotation,
|
||||
anchor.rotation,
|
||||
rotationBlend);
|
||||
}
|
||||
|
||||
private void FollowHolderTranslation(Vector3 holderPosition)
|
||||
{
|
||||
if (!hasPreviousHolderPosition)
|
||||
{
|
||||
previousHolderPosition = holderPosition;
|
||||
hasPreviousHolderPosition = true;
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 holderDelta = holderPosition - previousHolderPosition;
|
||||
previousHolderPosition = holderPosition;
|
||||
|
||||
transform.position += holderDelta;
|
||||
}
|
||||
|
||||
private void HandleHolderChanged(ulong _, ulong currentHolder) =>
|
||||
ApplyHoldingState(currentHolder != NoHolder);
|
||||
|
||||
private void ApplyHoldingState(bool isHeld)
|
||||
{
|
||||
followVelocity = Vector3.zero;
|
||||
hasPreviousHolderPosition = false;
|
||||
|
||||
if (physicsBody != null)
|
||||
{
|
||||
physicsBody.isKinematic = isHeld || !IsServer;
|
||||
physicsBody.linearVelocity = Vector3.zero;
|
||||
physicsBody.angularVelocity = Vector3.zero;
|
||||
bool shouldBeKinematic = isHeld || !IsServer;
|
||||
|
||||
if (physicsBody.isKinematic && !shouldBeKinematic)
|
||||
physicsBody.isKinematic = false;
|
||||
|
||||
if (!physicsBody.isKinematic)
|
||||
{
|
||||
physicsBody.linearVelocity = Vector3.zero;
|
||||
physicsBody.angularVelocity = Vector3.zero;
|
||||
}
|
||||
|
||||
physicsBody.isKinematic = shouldBeKinematic;
|
||||
}
|
||||
|
||||
if (isHeld)
|
||||
|
||||
Reference in New Issue
Block a user