Remove RemotePlayer prefab and script (use Player instead), implement jumping pckt
This commit is contained in:
parent
45954dab1a
commit
a0b286cbd6
@ -237,7 +237,6 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
Camera: {fileID: 9173392441446035453}
|
||||
DisableInput: 0
|
||||
TestingPlayer: {fileID: 0}
|
||||
--- !u!114 &3508289943927587728
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -291,34 +290,6 @@ PrefabInstance:
|
||||
propertyPath: m_TagString
|
||||
value: Player
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7391558912774766616, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7391558912774766616, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7391558912774766616, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7391558912774766616, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7391558912774766616, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7391558912774766616, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7391558912774766616, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7391558912774766616, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 0
|
||||
|
@ -43,4 +43,4 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 74110215548fa9145b867baf649d14b0, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
SpawnedRemotePlayer: {fileID: 6246660765983498204, guid: 0fd59d93bc0809e4c8bca733a842cb6f, type: 3}
|
||||
SpawnedRemotePlayer: {fileID: 7391558912774766599, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
|
@ -1,80 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &2280554230953742630
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6246660765983498204}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f10708676bd58ed419f4c9ab7caeec69, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1001 &3469055348080435163
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 7391558912774766599, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: RemotePlayer
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7391558912774766599, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_TagString
|
||||
value: RemotePlayer
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7391558912774766616, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7391558912774766616, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7391558912774766616, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7391558912774766616, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7391558912774766616, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7391558912774766616, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7391558912774766616, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7391558912774766616, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7391558912774766616, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7391558912774766616, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7391558912774766616, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
--- !u!1 &6246660765983498204 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 7391558912774766599, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
m_PrefabInstance: {fileID: 3469055348080435163}
|
||||
m_PrefabAsset: {fileID: 0}
|
@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0fd59d93bc0809e4c8bca733a842cb6f
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -78,7 +78,7 @@ namespace NeonTea.Quakeball.Networking.Instances {
|
||||
}
|
||||
} else if (packet is PlayerJumpPckt) {
|
||||
PlayerJumpPckt jump = (PlayerJumpPckt)packet;
|
||||
// Jump!
|
||||
Players[jump.PlayerId].Controlled.Jump();
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ namespace NeonTea.Quakeball.Networking.Instances {
|
||||
if (pckt.PlayerId == LocalPlayer.Id) {
|
||||
return; // Ignore, again.
|
||||
}
|
||||
Players[pckt.PlayerId].Controlled.GetComponent<RemotePlayer>().ProcessPacket(pckt);
|
||||
Players[pckt.PlayerId].Controlled.ProcessPacket(ref pckt);
|
||||
}
|
||||
|
||||
public override void UpdateLocalPlayer() {
|
||||
|
@ -78,17 +78,18 @@ namespace NeonTea.Quakeball.Networking.Instances {
|
||||
PlayerUpdatePckt updatePckt = (PlayerUpdatePckt)packet;
|
||||
if (Players[conn.uid].Controlled != null) {
|
||||
updatePckt.PlayerId = conn.uid;
|
||||
Players[conn.uid].Controlled.GetComponent<RemotePlayer>().ProcessPacket(updatePckt);
|
||||
Players[conn.uid].Controlled.ProcessPacket(ref updatePckt);
|
||||
}
|
||||
} else if (packet is PlayerJumpPckt) {
|
||||
PlayerJumpPckt jump = (PlayerJumpPckt)packet;
|
||||
if (Players[conn.uid].Controlled != null) {
|
||||
// Check if Players[conn.uid].Controlled can jump, and do the following if true
|
||||
if (Players[conn.uid].Controlled.Jump()) {
|
||||
jump.PlayerId = conn.uid;
|
||||
SendReliableToAll(jump);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SendReliableToAll(Packet packet, ulong except = ulong.MaxValue) {
|
||||
foreach (NetPlayer p in Players.Values) {
|
||||
|
@ -10,8 +10,6 @@ namespace NeonTea.Quakeball.Players {
|
||||
public Transform Camera;
|
||||
public bool DisableInput = false;
|
||||
|
||||
public RemotePlayer TestingPlayer;
|
||||
|
||||
private float Lean = 0;
|
||||
|
||||
private Player Player;
|
||||
@ -73,18 +71,21 @@ namespace NeonTea.Quakeball.Players {
|
||||
Camera.localEulerAngles = new Vector3(Player.Pitch, Player.Yaw, Lean);
|
||||
|
||||
if (Time.time - PreviousPlayerUpdate >= 1f / Player.UpdateFrequency) {
|
||||
PreviousPlayerUpdate = Time.time;
|
||||
|
||||
Vector2 MovementInput = MoveAction.ReadValue<Vector2>();
|
||||
Vector3 Move = new Vector3(MovementInput.x, 0, MovementInput.y);
|
||||
Move = Quaternion.Euler(0, Player.Yaw, 0) * Move;
|
||||
Player.MoveDirection = Move;
|
||||
Player.CurrentMoveStyle = CrouchAction.ReadValue<float>() > 0 ? (byte)1 : (byte)0;
|
||||
Player.Jumping = WantsToJump;
|
||||
PreviousPlayerUpdate = Time.time;
|
||||
WantsToJump = false;
|
||||
|
||||
if (Networking.Net.Singleton.Instance != null) {
|
||||
Networking.Net.Singleton.Instance.UpdateLocalPlayer();
|
||||
}
|
||||
|
||||
if (WantsToJump && Player.Jump()) {
|
||||
Networking.Net.Singleton.Instance.LocalPlayerJump();
|
||||
}
|
||||
WantsToJump = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,9 +31,6 @@ namespace NeonTea.Quakeball.Players {
|
||||
/// <summary>The direction the player is going.</summary>
|
||||
public Vector3 MoveDirection;
|
||||
|
||||
/// <summary>The player's desire to jump currently.</summary>
|
||||
public bool Jumping;
|
||||
|
||||
/// <summary>The amount of movement the player wants to happen.</summary>
|
||||
/// <remarks>Without analog controls, always 0 or 1.</remarks>
|
||||
public float InputSpeed;
|
||||
@ -90,6 +87,15 @@ namespace NeonTea.Quakeball.Players {
|
||||
}
|
||||
}
|
||||
|
||||
public bool Jump() {
|
||||
if (IsGrounded()) {
|
||||
GravitationalVelocity = Vector3.up * MoveStyle.JumpVelocity;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsGrounded() {
|
||||
return Time.time - GroundedTime <= CoyoteTime && Vector3.Dot(GravitationalVelocity, Vector3.down) >= 0;
|
||||
}
|
||||
@ -111,14 +117,10 @@ namespace NeonTea.Quakeball.Players {
|
||||
private void UpdateMovement() {
|
||||
bool Grounded = IsGrounded();
|
||||
|
||||
if (Grounded) {
|
||||
if (Vector3.Dot(Vector3.down, GravitationalVelocity) > 0) {
|
||||
bool FallingDown = Vector3.Dot(Vector3.down, GravitationalVelocity) > 0;
|
||||
if (Grounded && FallingDown) {
|
||||
GravitationalVelocity = Vector3.zero;
|
||||
}
|
||||
if (Jumping) {
|
||||
GravitationalVelocity = Vector3.up * MoveStyle.JumpVelocity;
|
||||
}
|
||||
} else {
|
||||
} else if (!Grounded) {
|
||||
GravitationalVelocity += Physics.gravity * Time.deltaTime;
|
||||
}
|
||||
|
||||
|
@ -1,19 +0,0 @@
|
||||
using UnityEngine;
|
||||
using NeonTea.Quakeball.Networking.Packets;
|
||||
using NeonTea.Quakeball.Interface;
|
||||
|
||||
namespace NeonTea.Quakeball.Players {
|
||||
/// <summary>A controller class for a remote player. Gets updates from the network and touches the relevant components.</summary>
|
||||
[RequireComponent(typeof(Player))]
|
||||
public class RemotePlayer : MonoBehaviour {
|
||||
private Player Player;
|
||||
|
||||
public void ProcessPacket(PlayerUpdatePckt packet) {
|
||||
Player.ProcessPacket(ref packet);
|
||||
}
|
||||
|
||||
private void Awake() {
|
||||
Player = GetComponent<Player>();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f10708676bd58ed419f4c9ab7caeec69
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 50
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user