netwo
This commit is contained in:
@@ -43,10 +43,7 @@ namespace Game
|
||||
[NetworkReplicated]
|
||||
public uint PlayerId = uint.MaxValue;
|
||||
|
||||
[NetworkReplicated]
|
||||
public uint hai = 1;
|
||||
|
||||
public PlayerActor()
|
||||
/*public PlayerActor()
|
||||
{
|
||||
// Default internal values for RigidBody
|
||||
IsKinematic = true;
|
||||
@@ -54,10 +51,17 @@ namespace Game
|
||||
LinearDamping = 0f;
|
||||
AngularDamping = 0f;
|
||||
Constraints = RigidbodyConstraints.LockRotation;
|
||||
}
|
||||
}*/
|
||||
|
||||
public override void OnBeginPlay()
|
||||
{
|
||||
// Default internal values for RigidBody
|
||||
IsKinematic = true;
|
||||
EnableGravity = false;
|
||||
LinearDamping = 0f;
|
||||
AngularDamping = 0f;
|
||||
Constraints = RigidbodyConstraints.LockRotation;
|
||||
|
||||
base.OnBeginPlay();
|
||||
|
||||
playerMovement = FindScript<PlayerMovement>();
|
||||
@@ -66,7 +70,7 @@ namespace Game
|
||||
|
||||
public override void OnEnable()
|
||||
{
|
||||
// Trigger OnEnable manually, does not seem to propagate when parent gets enabled/disabled
|
||||
// Trigger OnEnable manually, does not seem 8to propagate when parent gets enabled/disabled
|
||||
playerMovement.Enabled = true;
|
||||
//NetworkReplicator.AddObject(this);
|
||||
}
|
||||
@@ -77,10 +81,11 @@ namespace Game
|
||||
//NetworkReplicator.RemoveObject(this);
|
||||
}
|
||||
|
||||
[NetworkRpc(client: true)]
|
||||
public void Initialize(uint playerId)
|
||||
{
|
||||
PlayerId = playerId;
|
||||
//playerMovement.SetInput(playerId);
|
||||
playerMovement.SetInput(playerId);
|
||||
if (playerId == NetworkManager.LocalClientId)
|
||||
{
|
||||
FindActor("CameraHolder").IsActive = true;
|
||||
@@ -89,12 +94,17 @@ namespace Game
|
||||
}
|
||||
else
|
||||
FindActor("PlayerModel").IsActive = true;
|
||||
IsActive = true;
|
||||
}
|
||||
|
||||
public void UpdateNetworkInput(PlayerInputState inputState)
|
||||
[NetworkRpc(server: true)]
|
||||
public void UpdateNetworkInput(ulong frame, Float4 viewDeltaXYMoveForwardRight, bool attacking, bool jumping)
|
||||
{
|
||||
if (playerMovement.input is PlayerInputNetwork)
|
||||
(playerMovement.input as PlayerInputNetwork).currentState.input = inputState;
|
||||
if (playerMovement.input is not PlayerInputNetwork playerInputNetwork)
|
||||
return;
|
||||
|
||||
PlayerInputState inputState = new PlayerInputState(frame, viewDeltaXYMoveForwardRight.X, viewDeltaXYMoveForwardRight.Y, viewDeltaXYMoveForwardRight.Z, viewDeltaXYMoveForwardRight.W, attacking, jumping);
|
||||
playerInputNetwork.currentState.input = inputState;
|
||||
}
|
||||
|
||||
public void SetPosition(Float3 newPosition)
|
||||
@@ -107,6 +117,7 @@ namespace Game
|
||||
playerMovement.ResetRotation(eulerAngles);
|
||||
}
|
||||
|
||||
[NetworkRpc(client: true)]
|
||||
public void Teleport(Float3 newPosition, Float3 eulerAngles)
|
||||
{
|
||||
SetPosition(newPosition);
|
||||
|
||||
Reference in New Issue
Block a user