multiplayer stuff
This commit is contained in:
@@ -2,7 +2,10 @@
|
||||
using RebootKit.Engine.Foundation;
|
||||
using RebootKit.Engine.Main;
|
||||
using RebootKit.Engine.Services.Simulation;
|
||||
using RebootKit.Engine.Services.Simulation.Sensors;
|
||||
using RebootKit.Engine.Simulation;
|
||||
using RebootKit.Engine.Simulation.Sensors;
|
||||
using RebootReality.jelycho.Main;
|
||||
using Unity.Collections;
|
||||
using Unity.Mathematics;
|
||||
using Unity.Netcode;
|
||||
@@ -68,6 +71,11 @@ namespace RebootReality.jelycho.Player {
|
||||
[SerializeField] PhysicsObjectDragger m_PhysicsDragger;
|
||||
[SerializeField] FloatRange m_DragDistanceRange = new FloatRange(1.0f, 5.0f);
|
||||
|
||||
[Header("Beacon location picking")]
|
||||
[SerializeField] LayerMask m_BeaconPlacementLayerMask = 0;
|
||||
[SerializeField] float m_BeaconPlacementMaxDistance = 15.0f;
|
||||
[SerializeField] float m_NormalDotUpThreshold = 0.5f;
|
||||
|
||||
[Header("Network")]
|
||||
[SerializeField] float m_MinTeleportDistance = 0.5f;
|
||||
|
||||
@@ -302,13 +310,44 @@ namespace RebootReality.jelycho.Player {
|
||||
}
|
||||
|
||||
public void PrimaryAction() {
|
||||
m_Animator.SetTrigger(AnimatorParamHashes.Attack);
|
||||
if (!IsOwner) {
|
||||
s_Logger.Error("Only the owner can perform primary actions.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (TryGetBeaconPosition(out Vector3 beaconPosition)) {
|
||||
SetAnimatorTriggerRpc(AnimatorParamHashes.Throw);
|
||||
|
||||
GameWorldController.Instance.RequestBeaconSpawnRpc(beaconPosition);
|
||||
}
|
||||
}
|
||||
|
||||
public void SecondaryAction() {
|
||||
if (!IsOwner) {
|
||||
s_Logger.Error("Only the owner can perform secondary actions.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_Animator.SetTrigger(AnimatorParamHashes.Block);
|
||||
}
|
||||
|
||||
[Rpc(SendTo.Everyone)]
|
||||
void SetAnimatorTriggerRpc(int hash) {
|
||||
m_Animator.SetTrigger(hash);
|
||||
}
|
||||
|
||||
bool TryGetBeaconPosition(out Vector3 position) {
|
||||
Ray ray = new Ray(m_Camera.Camera.transform.position, m_Camera.Camera.transform.forward);
|
||||
if (Physics.Raycast(ray, out RaycastHit hit, m_BeaconPlacementMaxDistance, m_BeaconPlacementLayerMask) &&
|
||||
Vector3.Dot(hit.normal, Vector3.up) >= m_NormalDotUpThreshold) {
|
||||
position = hit.point;
|
||||
return true;
|
||||
}
|
||||
|
||||
position = Vector3.zero;
|
||||
return false;
|
||||
}
|
||||
|
||||
struct AnimatorParamHashes {
|
||||
public static readonly int VelocityForwardNormalized = Animator.StringToHash("VelocityForwardNormalized");
|
||||
public static readonly int VelocityRightNormalized = Animator.StringToHash("VelocityRightNormalized");
|
||||
@@ -317,6 +356,9 @@ namespace RebootReality.jelycho.Player {
|
||||
|
||||
public static readonly int Attack = Animator.StringToHash("Attack");
|
||||
public static readonly int Block = Animator.StringToHash("Block");
|
||||
public static readonly int Throw = Animator.StringToHash("Throw");
|
||||
|
||||
public static readonly int Holding = Animator.StringToHash("Holding");
|
||||
}
|
||||
|
||||
void UpdateAnimator(Vector3 velocity) {
|
||||
@@ -336,6 +378,7 @@ namespace RebootReality.jelycho.Player {
|
||||
m_Animator.SetFloat(AnimatorParamHashes.TurnVelocity, turnVelocity);
|
||||
|
||||
m_Animator.SetBool(AnimatorParamHashes.IsGrounded, m_Locomotion.IsGrounded);
|
||||
m_Animator.SetInteger(AnimatorParamHashes.Holding, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user