feat(Examples): Overhauled Examples (#3858)

* Added Player, Flyer, Tank Controllers

* and the meta

* Removed NT from Tank prefab

* Additive Scenes Player with new controller

* Updated Examples

* fixed healthbar

* Updated TankController

* Fixed MouseSteer

* Updated PlayerController

* Updated PlayerController

* Tank and Controller Updates

* Updated Tanks Navmesh

* Updated Tanks example

* Fixed Tank Model

* Tanks fixed

* Removed commented code

* Controller updates

* Projectile and Controller updates

* Tanks Navmesh

* Fixed navmesh

* Updated Projectile destroyAfter

* Update NavMesh

* Fixed spawn point

* TTA Scene Update

* TTA NavMesh

* TTA Tank Prefab

* Added Tank SeatedPlayer and turretAcceleration

* TTA Scene update

* TTA Scene higher walls

* Improved Projectile and PlayerTest

* Default Mouse Lock on

* IgnoreCollision

* Updated prefabs

* Latest

* Cleanup

* Disable sync position, Compress Rotation, and animation
- Animation is interfering with the controls and the child NT sync.

* Cleanup Reset on Disconnect

* Removed dead scripts
This commit is contained in:
MrGadget 2024-07-11 08:32:59 -04:00 committed by GitHub
parent 4a4ef9707c
commit 105607014f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
120 changed files with 18445 additions and 3447 deletions

View File

@ -282,28 +282,50 @@ MonoBehaviour:
m_GameObject: {fileID: 7619140271685878370}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 05e10150710dde14b83d3c8f5aa853c2, type: 3}
m_Script: {fileID: 11500000, guid: 9e212b6697536124ca0e7791fe5d8d6b, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 0
syncMode: 0
syncInterval: 0.1
syncInterval: 0
capsuleCollider: {fileID: -2422551836510166228}
characterController: {fileID: 5462452979215896872}
moveSpeedMultiplier: 8
ControllerUIPrefab: {fileID: 644766297742565710, guid: 7beee247444994f0281dadde274cc4af, type: 3}
moveKeys:
Forward: 119
Back: 115
StrafeLeft: 97
StrafeRight: 100
TurnLeft: 113
TurnRight: 101
Jump: 32
optionsKeys:
MouseSteer: 109
AutoRun: 114
ToggleUI: 117
controlOptions: 4
maxMoveSpeed: 8
inputSensitivity: 2
inputGravity: 2
initialJumpSpeed: 2.5
maxJumpSpeed: 3.5
jumpAcceleration: 4
maxTurnSpeed: 100
turnDelta: 3
initialJumpSpeed: 0.2
maxJumpSpeed: 5
jumpDelta: 0.2
turnAcceleration: 3
mouseSensitivity: 0.01
smoothTime: 0.2
groundState: 2
horizontal: 0
vertical: 0
turnSpeed: 0
jumpSpeed: 0
turnSpeed: 0
turnSmoothSpeed: 0
animVelocity: 0
animRotation: 0
velocity: {x: 0, y: 0, z: 0}
direction: {x: 0, y: 0, z: 0}
velocity: {x: 0, y: 0, z: 0}
mouseDelta: {x: 0, y: 0, z: 0}
controllerUI: {fileID: 0}
--- !u!143 &5462452979215896872
CharacterController:
m_ObjectHideFlags: 0

View File

@ -1,186 +0,0 @@
using UnityEngine;
namespace Mirror.Examples.AdditiveLevels
{
[RequireComponent(typeof(CapsuleCollider))]
[RequireComponent(typeof(CharacterController))]
[RequireComponent(typeof(NetworkTransformReliable))]
[RequireComponent(typeof(Rigidbody))]
public class PlayerController : NetworkBehaviour
{
public enum GroundState : byte { Jumping, Falling, Grounded }
[Header("Avatar Components")]
public CharacterController characterController;
[Header("Movement")]
[Range(1, 20)]
public float moveSpeedMultiplier = 8f;
[Header("Turning")]
[Range(1f, 200f)]
public float maxTurnSpeed = 100f;
[Range(.5f, 5f)]
public float turnDelta = 3f;
[Header("Jumping")]
[Range(0.1f, 1f)]
public float initialJumpSpeed = 0.2f;
[Range(1f, 10f)]
public float maxJumpSpeed = 5f;
[Range(0.1f, 1f)]
public float jumpDelta = 0.2f;
[Header("Diagnostics")]
[ReadOnly, SerializeField] GroundState groundState = GroundState.Grounded;
[ReadOnly, SerializeField, Range(-1f, 1f)]
float horizontal;
[ReadOnly, SerializeField, Range(-1f, 1f)]
float vertical;
[ReadOnly, SerializeField, Range(-200f, 200f)]
float turnSpeed;
[ReadOnly, SerializeField, Range(-10f, 10f)]
float jumpSpeed;
[ReadOnly, SerializeField, Range(-1.5f, 1.5f)]
float animVelocity;
[ReadOnly, SerializeField, Range(-1.5f, 1.5f)]
float animRotation;
[ReadOnly, SerializeField] Vector3Int velocity;
[ReadOnly, SerializeField] Vector3 direction;
protected override void OnValidate()
{
base.OnValidate();
if (characterController == null)
characterController = GetComponent<CharacterController>();
// Override CharacterController default values
characterController.enabled = false;
characterController.skinWidth = 0.02f;
characterController.minMoveDistance = 0f;
GetComponent<Rigidbody>().isKinematic = true;
this.enabled = false;
}
public override void OnStartAuthority()
{
characterController.enabled = true;
this.enabled = true;
}
public override void OnStopAuthority()
{
this.enabled = false;
characterController.enabled = false;
}
void Update()
{
if (!characterController.enabled)
return;
HandleTurning();
HandleJumping();
HandleMove();
// Reset ground state
if (characterController.isGrounded)
groundState = GroundState.Grounded;
else if (groundState != GroundState.Jumping)
groundState = GroundState.Falling;
// Diagnostic velocity...FloorToInt for display purposes
velocity = Vector3Int.FloorToInt(characterController.velocity);
}
// TODO: Turning works while airborne...feature?
void HandleTurning()
{
// Q and E cancel each other out, reducing the turn to zero.
if (Input.GetKey(KeyCode.Q))
turnSpeed = Mathf.MoveTowards(turnSpeed, -maxTurnSpeed, turnDelta);
if (Input.GetKey(KeyCode.E))
turnSpeed = Mathf.MoveTowards(turnSpeed, maxTurnSpeed, turnDelta);
// If both pressed, reduce turning speed toward zero.
if (Input.GetKey(KeyCode.Q) && Input.GetKey(KeyCode.E))
turnSpeed = Mathf.MoveTowards(turnSpeed, 0, turnDelta);
// If neither pressed, reduce turning speed toward zero.
if (!Input.GetKey(KeyCode.Q) && !Input.GetKey(KeyCode.E))
turnSpeed = Mathf.MoveTowards(turnSpeed, 0, turnDelta);
transform.Rotate(0f, turnSpeed * Time.deltaTime, 0f);
}
void HandleJumping()
{
// Handle variable force jumping.
// Jump starts with initial power on takeoff, and jumps higher / longer
// as player holds spacebar. Jump power is increased by a diminishing amout
// every frame until it reaches maxJumpSpeed, or player releases the spacebar,
// and then changes to the falling state until it gets grounded.
if (groundState != GroundState.Falling && Input.GetKey(KeyCode.Space))
{
if (groundState != GroundState.Jumping)
{
// Start jump at initial power.
groundState = GroundState.Jumping;
jumpSpeed = initialJumpSpeed;
}
else
// Jumping has already started...increase power toward maxJumpSpeed over time.
jumpSpeed = Mathf.MoveTowards(jumpSpeed, maxJumpSpeed, jumpDelta);
// If power has reached maxJumpSpeed, change to falling until grounded.
// This prevents over-applying jump power while already in the air.
if (jumpSpeed == maxJumpSpeed)
groundState = GroundState.Falling;
}
else if (groundState != GroundState.Grounded)
{
// handles running off a cliff and/or player released Spacebar.
groundState = GroundState.Falling;
jumpSpeed = Mathf.Min(jumpSpeed, maxJumpSpeed);
jumpSpeed += Physics.gravity.y * Time.deltaTime;
}
else
jumpSpeed = Physics.gravity.y * Time.deltaTime;
}
// TODO: Directional input works while airborne...feature?
void HandleMove()
{
// Capture inputs
horizontal = Input.GetAxis("Horizontal");
vertical = Input.GetAxis("Vertical");
// Create initial direction vector without jumpSpeed (y-axis).
direction = new Vector3(horizontal, 0f, vertical);
// Clamp so diagonal strafing isn't a speed advantage.
direction = Vector3.ClampMagnitude(direction, 1f);
// Transforms direction from local space to world space.
direction = transform.TransformDirection(direction);
// Multiply for desired ground speed.
direction *= moveSpeedMultiplier;
// Add jumpSpeed to direction as last step.
direction.y = jumpSpeed;
// Finally move the character.
characterController.Move(direction * Time.deltaTime);
}
}
}

View File

@ -43,11 +43,14 @@ public override void OnStartClient()
// up in the Physics collision matrix so only Player collides with Portal.
void OnTriggerEnter(Collider other)
{
if (!(other is CapsuleCollider)) return; // ignore CharacterController colliders
Debug.Log($"Portal.OnTriggerEnter {other}");
// tag check in case you didn't set up the layers and matrix as noted above
if (!other.CompareTag("Player")) return;
// applies to host client on server and remote clients
if (other.TryGetComponent(out PlayerController playerController))
if (other.TryGetComponent(out Common.Controllers.Player.PlayerController playerController))
playerController.enabled = false;
if (isServer)
@ -90,7 +93,7 @@ IEnumerator SendPlayerToNewScene(GameObject player)
// host client playerController would have been disabled by OnTriggerEnter above
// Remote client players are respawned with playerController already enabled
if (NetworkClient.localPlayer != null && NetworkClient.localPlayer.TryGetComponent(out PlayerController playerController))
if (NetworkClient.localPlayer != null && NetworkClient.localPlayer.TryGetComponent(out Common.Controllers.Player.PlayerController playerController))
playerController.enabled = true;
}
}

View File

@ -1,156 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!91 &9100000
AnimatorController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Tank
serializedVersion: 5
m_AnimatorParameters:
- m_Name: Fire
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
m_StateMachine: {fileID: 1107206089488630588}
m_Mask: {fileID: 0}
m_Motions: []
m_Behaviours: []
m_BlendingMode: 0
m_SyncedLayerIndex: -1
m_DefaultWeight: 0
m_IKPass: 0
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
--- !u!1101 &1101845105868117086
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: Fire
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102477577393645330}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.45454544
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &1101857281332299900
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102845660080023070}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.058695674
m_TransitionOffset: 0.41739127
m_ExitTime: 0.9060869
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1102 &1102477577393645330
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Recon_Tank_Rig|Shoot
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: 1101857281332299900}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400006, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1102 &1102845660080023070
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Recon_Tank_Rig|Idle
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: 1101845105868117086}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400004, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1107 &1107206089488630588
AnimatorStateMachine:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Base Layer
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 1102845660080023070}
m_Position: {x: 132, y: 300, z: 0}
- serializedVersion: 1
m_State: {fileID: 1102477577393645330}
m_Position: {x: 360, y: 432, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 50, y: 20, z: 0}
m_EntryPosition: {x: 50, y: 120, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: 1102845660080023070}

View File

@ -283,28 +283,50 @@ MonoBehaviour:
m_GameObject: {fileID: 8872462076811691049}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e8f68561248aaca4fb96847ce24742ee, type: 3}
m_Script: {fileID: 11500000, guid: 9e212b6697536124ca0e7791fe5d8d6b, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 0
syncMode: 0
syncInterval: 0.1
syncInterval: 0
capsuleCollider: {fileID: 1143206540915927667}
characterController: {fileID: 8993127209816276930}
moveSpeedMultiplier: 8
ControllerUIPrefab: {fileID: 644766297742565710, guid: 7beee247444994f0281dadde274cc4af, type: 3}
moveKeys:
Forward: 119
Back: 115
StrafeLeft: 97
StrafeRight: 100
TurnLeft: 113
TurnRight: 101
Jump: 32
optionsKeys:
MouseSteer: 109
AutoRun: 114
ToggleUI: 117
controlOptions: 4
maxMoveSpeed: 8
inputSensitivity: 2
inputGravity: 2
initialJumpSpeed: 2.5
maxJumpSpeed: 3.5
jumpAcceleration: 4
maxTurnSpeed: 100
turnDelta: 1
initialJumpSpeed: 0.2
maxJumpSpeed: 5
jumpDelta: 0.2
turnAcceleration: 3
mouseSensitivity: 0.01
smoothTime: 0.2
groundState: 2
horizontal: 0
vertical: 0
turnSpeed: 0
jumpSpeed: 0
turnSpeed: 0
turnSmoothSpeed: 0
animVelocity: 0
animRotation: 0
velocity: {x: 0, y: 0, z: 0}
direction: {x: 0, y: 0, z: 0}
velocity: {x: 0, y: 0, z: 0}
mouseDelta: {x: 0, y: 0, z: 0}
controllerUI: {fileID: 0}
--- !u!143 &8993127209816276930
CharacterController:
m_ObjectHideFlags: 0

View File

@ -11,8 +11,8 @@ GameObject:
- component: {fileID: 160176456}
- component: {fileID: 160176459}
- component: {fileID: 160176461}
- component: {fileID: 160176460}
- component: {fileID: 160176462}
- component: {fileID: 8459448276305187380}
m_Layer: 0
m_Name: Tank
m_TagString: Untagged
@ -27,15 +27,14 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 160176457}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 5, y: 5, z: 5}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 3234001708628876000}
- {fileID: 1042389410631263445}
- {fileID: 2007627003840388256}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &160176459
MonoBehaviour:
@ -52,7 +51,7 @@ MonoBehaviour:
sceneId: 0
_assetId: 635825396
serverOnly: 0
visible: 0
visibility: 0
hasSpawned: 0
--- !u!114 &160176461
MonoBehaviour:
@ -70,28 +69,7 @@ MonoBehaviour:
syncMode: 0
syncInterval: 0.1
clientAuthority: 0
animator: {fileID: 160176460}
--- !u!95 &160176460
Animator:
serializedVersion: 5
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 160176457}
m_Enabled: 1
m_Avatar: {fileID: 9000000, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
m_Controller: {fileID: 9100000, guid: e0dbc8b2f2711a54f9b7ed1358a4c6af, type: 2}
m_CullingMode: 1
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_StabilizeFeet: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 0
m_WriteDefaultValuesOnDisable: 0
animator: {fileID: 2007627003849978698}
--- !u!114 &160176462
MonoBehaviour:
m_ObjectHideFlags: 0
@ -109,493 +87,86 @@ MonoBehaviour:
syncInterval: 0.1
rotation: {x: 0, y: 0, z: 0, w: 0}
turnSpeed: 0.1
--- !u!1 &489699669850839237
GameObject:
--- !u!114 &8459448276305187380
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6048638457609172120}
m_Layer: 0
m_Name: Wheel_Rear_L_end
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6048638457609172120
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 489699669850839237}
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0, y: 0.0021921142, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5371032128924763904}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &739025013192983599
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1766344861363284577}
m_Layer: 0
m_Name: Wheel_Middle_L
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1766344861363284577
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 739025013192983599}
m_LocalRotation: {x: -0.5, y: 0.5, z: 0.49999994, w: 0.50000006}
m_LocalPosition: {x: -0, y: 0.0011627917, z: 0.0000000010728836}
m_LocalScale: {x: 1, y: 0.99999994, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 9163197381092130014}
m_Father: {fileID: 847897825935598517}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1014401586714983030
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7755980514232685276}
m_Layer: 0
m_Name: Turret
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7755980514232685276
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1014401586714983030}
m_LocalRotation: {x: 0, y: -0.000000119209275, z: -0, w: 1}
m_LocalPosition: {x: -0, y: 0.0010293524, z: 0}
m_LocalScale: {x: 1, y: 0.99999994, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1517159280684637724}
m_Father: {fileID: 1703734463393124925}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1218215768088827738
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5371032128924763904}
m_Layer: 0
m_Name: Wheel_Rear_L
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5371032128924763904
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1218215768088827738}
m_LocalRotation: {x: -0.5, y: 0.5, z: 0.49999994, w: 0.50000006}
m_LocalPosition: {x: -0, y: 0.0011627917, z: -0.0026999994}
m_LocalScale: {x: 1, y: 0.99999994, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 6048638457609172120}
m_Father: {fileID: 847897825935598517}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2620739405153902494
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7509984371715941402}
m_Layer: 0
m_Name: Barrel_end
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7509984371715941402
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2620739405153902494}
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0, y: 0.0063666296, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1517159280684637724}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &4300763244710219681
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3234001708628876000}
- component: {fileID: 2715744559599808281}
- component: {fileID: 4300454509241183841}
m_Layer: 0
m_Name: Recon_Tank
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3234001708628876000
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4300763244710219681}
m_LocalRotation: {x: -0.7071068, y: 0, z: -0, w: 0.7071067}
m_LocalPosition: {x: -0, y: 0, z: 0}
m_LocalScale: {x: 100, y: 100, z: 100}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 160176456}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!137 &2715744559599808281
SkinnedMeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4300763244710219681}
m_GameObject: {fileID: 160176457}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 2e67e42170aa64aa9a33424f8045ac89, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b2e242ee38a14076a39934172a19079b, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 0
syncMode: 0
syncInterval: 0
visRange: 10
--- !u!1001 &3000458335636939717
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Quality: 0
m_UpdateWhenOffscreen: 0
m_SkinnedMotionVectors: 1
m_Mesh: {fileID: 4300000, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
m_Bones:
- {fileID: 847897825935598517}
- {fileID: 1703734463393124925}
- {fileID: 7755980514232685276}
- {fileID: 1517159280684637724}
- {fileID: 7124543900430328667}
- {fileID: 1766344861363284577}
- {fileID: 5371032128924763904}
m_BlendShapeWeights: []
m_RootBone: {fileID: 847897825935598517}
m_AABB:
m_Center: {x: 0, y: 0.0041689305, z: 0.0018957809}
m_Extent: {x: 0.0028734768, y: 0.004266139, z: 0.006842426}
m_DirtyAABB: 0
--- !u!64 &4300454509241183841
MeshCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4300763244710219681}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 4
m_Convex: 0
m_CookingOptions: 30
m_Mesh: {fileID: 4300000, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
--- !u!1 &4728827432125738153
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 847897825935598517}
m_Layer: 0
m_Name: Root
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &847897825935598517
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 160176456}
m_Modifications:
- target: {fileID: 3638700596990255941, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_Name
value: BasePrefab
objectReference: {fileID: 0}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalPosition.y
value: 0.05
objectReference: {fileID: 0}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
--- !u!4 &2007627003840388256 stripped
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
m_PrefabInstance: {fileID: 3000458335636939717}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4728827432125738153}
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071067}
m_LocalPosition: {x: -0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1703734463393124925}
- {fileID: 7124543900430328667}
- {fileID: 1766344861363284577}
- {fileID: 5371032128924763904}
m_Father: {fileID: 1042389410631263445}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &5311698857118067376
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
--- !u!95 &2007627003849978698 stripped
Animator:
m_CorrespondingSourceObject: {fileID: 3638700596980764815, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
m_PrefabInstance: {fileID: 3000458335636939717}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7124543900430328667}
m_Layer: 0
m_Name: Wheel_Front_L
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7124543900430328667
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5311698857118067376}
m_LocalRotation: {x: -0.5, y: 0.5, z: 0.49999994, w: 0.50000006}
m_LocalPosition: {x: -0, y: 0.0011627917, z: 0.0027000008}
m_LocalScale: {x: 1, y: 0.99999994, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 5752532462053122769}
m_Father: {fileID: 847897825935598517}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &5804173475777962202
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1703734463393124925}
m_Layer: 0
m_Name: Chasis
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1703734463393124925
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5804173475777962202}
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0, y: 0.0015, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 7755980514232685276}
m_Father: {fileID: 847897825935598517}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &6536093484198670798
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1517159280684637724}
m_Layer: 0
m_Name: Barrel
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1517159280684637724
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6536093484198670798}
m_LocalRotation: {x: 0.00000017845065, y: 0.7071068, z: 0.7071067, w: 0.000000009863265}
m_LocalPosition: {x: 5.6542865e-10, y: 0.0015793034, z: 0.00237158}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 7509984371715941402}
m_Father: {fileID: 7755980514232685276}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &7509875135952387032
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1042389410631263445}
m_Layer: 0
m_Name: Recon_Tank_Rig
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1042389410631263445
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7509875135952387032}
m_LocalRotation: {x: -0.7071068, y: 0, z: -0, w: 0.7071067}
m_LocalPosition: {x: -0, y: 0, z: 0}
m_LocalScale: {x: 100, y: 100, z: 100}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 847897825935598517}
m_Father: {fileID: 160176456}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &7895955422738415095
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5752532462053122769}
m_Layer: 0
m_Name: Wheel_Front_L_end
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5752532462053122769
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7895955422738415095}
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0, y: 0.0021921142, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7124543900430328667}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &8824818431311294599
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 9163197381092130014}
m_Layer: 0
m_Name: Wheel_Middle_L_end
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &9163197381092130014
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8824818431311294599}
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0, y: 0.0021921142, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1766344861363284577}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View File

@ -1,186 +0,0 @@
using UnityEngine;
namespace Mirror.Examples.AdditiveScenes
{
[RequireComponent(typeof(CapsuleCollider))]
[RequireComponent(typeof(CharacterController))]
[RequireComponent(typeof(NetworkTransformReliable))]
[RequireComponent(typeof(Rigidbody))]
public class PlayerController : NetworkBehaviour
{
public enum GroundState : byte { Jumping, Falling, Grounded }
[Header("Avatar Components")]
public CharacterController characterController;
[Header("Movement")]
[Range(1, 20)]
public float moveSpeedMultiplier = 8f;
[Header("Turning")]
[Range(1f, 200f)]
public float maxTurnSpeed = 100f;
[Range(.5f, 5f)]
public float turnDelta = 3f;
[Header("Jumping")]
[Range(0.1f, 1f)]
public float initialJumpSpeed = 0.2f;
[Range(1f, 10f)]
public float maxJumpSpeed = 5f;
[Range(0.1f, 1f)]
public float jumpDelta = 0.2f;
[Header("Diagnostics")]
[ReadOnly, SerializeField] GroundState groundState = GroundState.Grounded;
[ReadOnly, SerializeField, Range(-1f, 1f)]
float horizontal;
[ReadOnly, SerializeField, Range(-1f, 1f)]
float vertical;
[ReadOnly, SerializeField, Range(-200f, 200f)]
float turnSpeed;
[ReadOnly, SerializeField, Range(-10f, 10f)]
float jumpSpeed;
[ReadOnly, SerializeField, Range(-1.5f, 1.5f)]
float animVelocity;
[ReadOnly, SerializeField, Range(-1.5f, 1.5f)]
float animRotation;
[ReadOnly, SerializeField] Vector3Int velocity;
[ReadOnly, SerializeField] Vector3 direction;
protected override void OnValidate()
{
base.OnValidate();
if (characterController == null)
characterController = GetComponent<CharacterController>();
// Override CharacterController default values
characterController.enabled = false;
characterController.skinWidth = 0.02f;
characterController.minMoveDistance = 0f;
GetComponent<Rigidbody>().isKinematic = true;
this.enabled = false;
}
public override void OnStartAuthority()
{
characterController.enabled = true;
this.enabled = true;
}
public override void OnStopAuthority()
{
this.enabled = false;
characterController.enabled = false;
}
void Update()
{
if (!characterController.enabled)
return;
HandleTurning();
HandleJumping();
HandleMove();
// Reset ground state
if (characterController.isGrounded)
groundState = GroundState.Grounded;
else if (groundState != GroundState.Jumping)
groundState = GroundState.Falling;
// Diagnostic velocity...FloorToInt for display purposes
velocity = Vector3Int.FloorToInt(characterController.velocity);
}
// TODO: Turning works while airborne...feature?
void HandleTurning()
{
// Q and E cancel each other out, reducing the turn to zero.
if (Input.GetKey(KeyCode.Q))
turnSpeed = Mathf.MoveTowards(turnSpeed, -maxTurnSpeed, turnDelta);
if (Input.GetKey(KeyCode.E))
turnSpeed = Mathf.MoveTowards(turnSpeed, maxTurnSpeed, turnDelta);
// If both pressed, reduce turning speed toward zero.
if (Input.GetKey(KeyCode.Q) && Input.GetKey(KeyCode.E))
turnSpeed = Mathf.MoveTowards(turnSpeed, 0, turnDelta);
// If neither pressed, reduce turning speed toward zero.
if (!Input.GetKey(KeyCode.Q) && !Input.GetKey(KeyCode.E))
turnSpeed = Mathf.MoveTowards(turnSpeed, 0, turnDelta);
transform.Rotate(0f, turnSpeed * Time.deltaTime, 0f);
}
void HandleJumping()
{
// Handle variable force jumping.
// Jump starts with initial power on takeoff, and jumps higher / longer
// as player holds spacebar. Jump power is increased by a diminishing amout
// every frame until it reaches maxJumpSpeed, or player releases the spacebar,
// and then changes to the falling state until it gets grounded.
if (groundState != GroundState.Falling && Input.GetKey(KeyCode.Space))
{
if (groundState != GroundState.Jumping)
{
// Start jump at initial power.
groundState = GroundState.Jumping;
jumpSpeed = initialJumpSpeed;
}
else
// Jumping has already started...increase power toward maxJumpSpeed over time.
jumpSpeed = Mathf.MoveTowards(jumpSpeed, maxJumpSpeed, jumpDelta);
// If power has reached maxJumpSpeed, change to falling until grounded.
// This prevents over-applying jump power while already in the air.
if (jumpSpeed == maxJumpSpeed)
groundState = GroundState.Falling;
}
else if (groundState != GroundState.Grounded)
{
// handles running off a cliff and/or player released Spacebar.
groundState = GroundState.Falling;
jumpSpeed = Mathf.Min(jumpSpeed, maxJumpSpeed);
jumpSpeed += Physics.gravity.y * Time.deltaTime;
}
else
jumpSpeed = Physics.gravity.y * Time.deltaTime;
}
// TODO: Directional input works while airborne...feature?
void HandleMove()
{
// Capture inputs
horizontal = Input.GetAxis("Horizontal");
vertical = Input.GetAxis("Vertical");
// Create initial direction vector without jumpSpeed (y-axis).
direction = new Vector3(horizontal, 0f, vertical);
// Clamp so diagonal strafing isn't a speed advantage.
direction = Vector3.ClampMagnitude(direction, 1f);
// Transforms direction from local space to world space.
direction = transform.TransformDirection(direction);
// Multiply for desired ground speed.
direction *= moveSpeedMultiplier;
// Add jumpSpeed to direction as last step.
direction.y = jumpSpeed;
// Finally move the character.
characterController.Move(direction * Time.deltaTime);
}
}
}

View File

@ -50,9 +50,9 @@ void ShootNearestPlayer()
if (target != null)
{
transform.LookAt(target.transform.position + Vector3.down);
transform.LookAt(new Vector3(target.transform.position.x, 0, target.transform.position.z));
rotation = transform.rotation;
networkAnimator.SetTrigger("Fire");
//networkAnimator.SetTrigger("Shoot");
}
}
}

View File

@ -190,6 +190,8 @@ MonoBehaviour:
syncDirection: 0
syncMode: 0
syncInterval: 0.1
offset: {x: 0, y: 3, z: -8}
rotation: {x: 10, y: 0, z: 0}
--- !u!114 &114892629901890886
MonoBehaviour:
m_ObjectHideFlags: 0
@ -199,28 +201,48 @@ MonoBehaviour:
m_GameObject: {fileID: 1480027675339556}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 479a5196564ede84791870b414a13645, type: 3}
m_Script: {fileID: 11500000, guid: 9e212b6697536124ca0e7791fe5d8d6b, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 0
syncMode: 0
syncInterval: 0.1
syncInterval: 0
capsuleCollider: {fileID: 4839740653866577337}
characterController: {fileID: 143011667059871024}
moveSpeedMultiplier: 8
ControllerUIPrefab: {fileID: 644766297742565710, guid: 7beee247444994f0281dadde274cc4af, type: 3}
moveKeys:
Forward: 119
Back: 115
StrafeLeft: 97
StrafeRight: 100
TurnLeft: 113
TurnRight: 101
Jump: 32
optionsKeys:
MouseSteer: 109
AutoRun: 114
ToggleUI: 117
controlOptions: 4
maxMoveSpeed: 8
inputSensitivity: 2
inputGravity: 2
initialJumpSpeed: 2.5
maxJumpSpeed: 3.5
jumpAcceleration: 4
maxTurnSpeed: 100
turnDelta: 1
initialJumpSpeed: 0.2
maxJumpSpeed: 5
jumpDelta: 0.2
turnAcceleration: 3
groundState: 2
horizontal: 0
vertical: 0
mouseInputX: 0
mouseSensitivity: 0
turnSpeed: 0
jumpSpeed: 0
animVelocity: 0
animRotation: 0
velocity: {x: 0, y: 0, z: 0}
direction: {x: 0, y: 0, z: 0}
velocity: {x: 0, y: 0, z: 0}
controllerUI: {fileID: 0}
--- !u!143 &143011667059871024
CharacterController:
m_ObjectHideFlags: 0

View File

@ -1,186 +0,0 @@
using UnityEngine;
namespace Mirror.Examples.MultipleAdditiveScenes
{
[RequireComponent(typeof(CapsuleCollider))]
[RequireComponent(typeof(CharacterController))]
[RequireComponent(typeof(NetworkTransformReliable))]
[RequireComponent(typeof(Rigidbody))]
public class PlayerController : NetworkBehaviour
{
public enum GroundState : byte { Jumping, Falling, Grounded }
[Header("Avatar Components")]
public CharacterController characterController;
[Header("Movement")]
[Range(1, 20)]
public float moveSpeedMultiplier = 8f;
[Header("Turning")]
[Range(1f, 200f)]
public float maxTurnSpeed = 100f;
[Range(.5f, 5f)]
public float turnDelta = 3f;
[Header("Jumping")]
[Range(0.1f, 1f)]
public float initialJumpSpeed = 0.2f;
[Range(1f, 10f)]
public float maxJumpSpeed = 5f;
[Range(0.1f, 1f)]
public float jumpDelta = 0.2f;
[Header("Diagnostics")]
[ReadOnly, SerializeField] GroundState groundState = GroundState.Grounded;
[ReadOnly, SerializeField, Range(-1f, 1f)]
float horizontal;
[ReadOnly, SerializeField, Range(-1f, 1f)]
float vertical;
[ReadOnly, SerializeField, Range(-200f, 200f)]
float turnSpeed;
[ReadOnly, SerializeField, Range(-10f, 10f)]
float jumpSpeed;
[ReadOnly, SerializeField, Range(-1.5f, 1.5f)]
float animVelocity;
[ReadOnly, SerializeField, Range(-1.5f, 1.5f)]
float animRotation;
[ReadOnly, SerializeField] Vector3Int velocity;
[ReadOnly, SerializeField] Vector3 direction;
protected override void OnValidate()
{
base.OnValidate();
if (characterController == null)
characterController = GetComponent<CharacterController>();
// Override CharacterController default values
characterController.enabled = false;
characterController.skinWidth = 0.02f;
characterController.minMoveDistance = 0f;
GetComponent<Rigidbody>().isKinematic = true;
this.enabled = false;
}
public override void OnStartAuthority()
{
characterController.enabled = true;
this.enabled = true;
}
public override void OnStopAuthority()
{
this.enabled = false;
characterController.enabled = false;
}
void Update()
{
if (!characterController.enabled)
return;
HandleTurning();
HandleJumping();
HandleMove();
// Reset ground state
if (characterController.isGrounded)
groundState = GroundState.Grounded;
else if (groundState != GroundState.Jumping)
groundState = GroundState.Falling;
// Diagnostic velocity...FloorToInt for display purposes
velocity = Vector3Int.FloorToInt(characterController.velocity);
}
// TODO: Turning works while airborne...feature?
void HandleTurning()
{
// Q and E cancel each other out, reducing the turn to zero.
if (Input.GetKey(KeyCode.Q))
turnSpeed = Mathf.MoveTowards(turnSpeed, -maxTurnSpeed, turnDelta);
if (Input.GetKey(KeyCode.E))
turnSpeed = Mathf.MoveTowards(turnSpeed, maxTurnSpeed, turnDelta);
// If both pressed, reduce turning speed toward zero.
if (Input.GetKey(KeyCode.Q) && Input.GetKey(KeyCode.E))
turnSpeed = Mathf.MoveTowards(turnSpeed, 0, turnDelta);
// If neither pressed, reduce turning speed toward zero.
if (!Input.GetKey(KeyCode.Q) && !Input.GetKey(KeyCode.E))
turnSpeed = Mathf.MoveTowards(turnSpeed, 0, turnDelta);
transform.Rotate(0f, turnSpeed * Time.deltaTime, 0f);
}
void HandleJumping()
{
// Handle variable force jumping.
// Jump starts with initial power on takeoff, and jumps higher / longer
// as player holds spacebar. Jump power is increased by a diminishing amout
// every frame until it reaches maxJumpSpeed, or player releases the spacebar,
// and then changes to the falling state until it gets grounded.
if (groundState != GroundState.Falling && Input.GetKey(KeyCode.Space))
{
if (groundState != GroundState.Jumping)
{
// Start jump at initial power.
groundState = GroundState.Jumping;
jumpSpeed = initialJumpSpeed;
}
else
// Jumping has already started...increase power toward maxJumpSpeed over time.
jumpSpeed = Mathf.MoveTowards(jumpSpeed, maxJumpSpeed, jumpDelta);
// If power has reached maxJumpSpeed, change to falling until grounded.
// This prevents over-applying jump power while already in the air.
if (jumpSpeed == maxJumpSpeed)
groundState = GroundState.Falling;
}
else if (groundState != GroundState.Grounded)
{
// handles running off a cliff and/or player released Spacebar.
groundState = GroundState.Falling;
jumpSpeed = Mathf.Min(jumpSpeed, maxJumpSpeed);
jumpSpeed += Physics.gravity.y * Time.deltaTime;
}
else
jumpSpeed = Physics.gravity.y * Time.deltaTime;
}
// TODO: Directional input works while airborne...feature?
void HandleMove()
{
// Capture inputs
horizontal = Input.GetAxis("Horizontal");
vertical = Input.GetAxis("Vertical");
// Create initial direction vector without jumpSpeed (y-axis).
direction = new Vector3(horizontal, 0f, vertical);
// Clamp so diagonal strafing isn't a speed advantage.
direction = Vector3.ClampMagnitude(direction, 1f);
// Transforms direction from local space to world space.
direction = transform.TransformDirection(direction);
// Multiply for desired ground speed.
direction *= moveSpeedMultiplier;
// Add jumpSpeed to direction as last step.
direction.y = jumpSpeed;
// Finally move the character.
characterController.Move(direction * Time.deltaTime);
}
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 6878aacf12b204d03a94f71e49f9ad60
guid: c34b16365299ef142b274ad19bd88370
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -0,0 +1,421 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &4592122871669721618
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5246057292441020322}
- component: {fileID: 7450643213444322531}
- component: {fileID: 2343013367479929851}
m_Layer: 0
m_Name: Visor
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5246057292441020322
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4592122871669721618}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0.39999998, z: 0.5}
m_LocalScale: {x: 0.5, y: 0.1, z: 0.2}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3834521907656645861}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &7450643213444322531
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4592122871669721618}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &2343013367479929851
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4592122871669721618}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 4294967295
m_RendererPriority: 0
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &5844787331012650587
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3834521907656645861}
- component: {fileID: 7647174189108629449}
- component: {fileID: 1712964438743777021}
m_Layer: 0
m_Name: Capsule
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3834521907656645861
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5844787331012650587}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 5246057292441020322}
m_Father: {fileID: 4659514702152478195}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &7647174189108629449
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5844787331012650587}
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &1712964438743777021
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5844787331012650587}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 792117fe9a386a8489e8010bec746339, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &7863680369626900553
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4659514702152478195}
- component: {fileID: 4284051235536850638}
- component: {fileID: 1014105431373575527}
- component: {fileID: 3857390224898622435}
- component: {fileID: 5870539754798150155}
- component: {fileID: 5382001159774817068}
- component: {fileID: -218831818502395344}
- component: {fileID: 6315922853844755037}
- component: {fileID: 508331813320017038}
m_Layer: 0
m_Name: PlayerPrefab
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4659514702152478195
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1.1, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 3834521907656645861}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!136 &4284051235536850638
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Height: 2
m_Direction: 1
m_Center: {x: 0, y: 0, z: 0}
--- !u!143 &1014105431373575527
CharacterController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 0
serializedVersion: 3
m_Height: 2
m_Radius: 0.5
m_SlopeLimit: 45
m_StepOffset: 0.3
m_SkinWidth: 0.02
m_MinMoveDistance: 0
m_Center: {x: 0, y: 0, z: 0}
--- !u!54 &3857390224898622435
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
serializedVersion: 4
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_CenterOfMass: {x: 0, y: 0, z: 0}
m_InertiaTensor: {x: 1, y: 1, z: 1}
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_ImplicitCom: 1
m_ImplicitTensor: 1
m_UseGravity: 1
m_IsKinematic: 1
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!114 &5870539754798150155
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9b91ecbcc199f4492b9a91e820070131, type: 3}
m_Name:
m_EditorClassIdentifier:
sceneId: 0
_assetId: 810734400
serverOnly: 0
visibility: 0
hasSpawned: 0
--- !u!114 &5382001159774817068
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8ff3ba0becae47b8b9381191598957c8, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 1
syncMode: 0
syncInterval: 0
target: {fileID: 4659514702152478195}
syncPosition: 1
syncRotation: 1
syncScale: 0
onlySyncOnChange: 1
compressRotation: 1
interpolatePosition: 1
interpolateRotation: 1
interpolateScale: 1
coordinateSpace: 0
sendIntervalMultiplier: 1
timelineOffset: 0
showGizmos: 0
showOverlay: 0
overlayColor: {r: 0, g: 0, b: 0, a: 0.5}
onlySyncOnChangeCorrectionMultiplier: 2
rotationSensitivity: 0.01
positionPrecision: 0.01
scalePrecision: 0.01
--- !u!114 &-218831818502395344
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9e212b6697536124ca0e7791fe5d8d6b, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 0
syncMode: 0
syncInterval: 0
characterController: {fileID: 1014105431373575527}
ControllerUIPrefab: {fileID: 644766297742565710, guid: 7beee247444994f0281dadde274cc4af, type: 3}
moveKeys:
Forward: 119
Back: 115
StrafeLeft: 97
StrafeRight: 100
TurnLeft: 113
TurnRight: 101
Jump: 32
optionsKeys:
MouseSteer: 109
AutoRun: 114
ToggleUI: 117
controlOptions: 4
maxMoveSpeed: 8
inputSensitivity: 2
inputGravity: 2
initialJumpSpeed: 2.5
maxJumpSpeed: 3.5
jumpAcceleration: 4
maxTurnSpeed: 100
turnAcceleration: 3
groundState: 2
horizontal: 0
vertical: 0
mouseInputX: 0
mouseSensitivity: 0
turnSpeed: 0
jumpSpeed: 0
animVelocity: 0
animRotation: 0
direction: {x: 0, y: 0, z: 0}
velocity: {x: 0, y: 0, z: 0}
controllerUI: {fileID: 0}
--- !u!114 &6315922853844755037
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a91a718a70d01b347b75cb768a6f1a92, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 0
syncMode: 0
syncInterval: 0
color:
serializedVersion: 2
rgba: 4278190080
--- !u!114 &508331813320017038
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 71ac1e35462ffad469e77d1c2fe6c9f3, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 0
syncMode: 0
syncInterval: 0
offset: {x: 0, y: 3, z: -8}
rotation: {x: 10, y: 0, z: 0}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 34c79b503a7a04847be9745d119b655d
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,265 @@
using System;
using UnityEngine;
using UnityEngine.SceneManagement;
using Mirror;
using System.Collections;
/*
Documentation: https://mirror-networking.gitbook.io/docs/components/network-manager
API Reference: https://mirror-networking.com/docs/api/Mirror.NetworkManager.html
*/
namespace Mirror.Examples.PlayerTest
{
public class PlayerTestNetMan : NetworkManager
{
// Overrides the base singleton so we don't
// have to cast to this type everywhere.
public static new PlayerTestNetMan singleton => (PlayerTestNetMan)NetworkManager.singleton;
/// <summary>
/// Runs on both Server and Client
/// Networking is NOT initialized when this fires
/// </summary>
public override void Awake()
{
base.Awake();
}
#region Unity Callbacks
public override void OnValidate()
{
base.OnValidate();
}
/// <summary>
/// Runs on both Server and Client
/// Networking is NOT initialized when this fires
/// </summary>
public override void Start()
{
base.Start();
}
/// <summary>
/// Runs on both Server and Client
/// </summary>
public override void LateUpdate()
{
base.LateUpdate();
}
/// <summary>
/// Runs on both Server and Client
/// </summary>
public override void OnDestroy()
{
base.OnDestroy();
}
#endregion
#region Start & Stop
/// <summary>
/// Set the frame rate for a headless server.
/// <para>Override if you wish to disable the behavior or set your own tick rate.</para>
/// </summary>
public override void ConfigureHeadlessFrameRate()
{
base.ConfigureHeadlessFrameRate();
}
/// <summary>
/// called when quitting the application by closing the window / pressing stop in the editor
/// </summary>
public override void OnApplicationQuit()
{
base.OnApplicationQuit();
}
#endregion
#region Scene Management
/// <summary>
/// This causes the server to switch scenes and sets the networkSceneName.
/// <para>Clients that connect to this server will automatically switch to this scene. This is called automatically if onlineScene or offlineScene are set, but it can be called from user code to switch scenes again while the game is in progress. This automatically sets clients to be not-ready. The clients must call NetworkClient.Ready() again to participate in the new scene.</para>
/// </summary>
/// <param name="newSceneName"></param>
public override void ServerChangeScene(string newSceneName)
{
base.ServerChangeScene(newSceneName);
}
/// <summary>
/// Called from ServerChangeScene immediately before SceneManager.LoadSceneAsync is executed
/// <para>This allows server to do work / cleanup / prep before the scene changes.</para>
/// </summary>
/// <param name="newSceneName">Name of the scene that's about to be loaded</param>
public override void OnServerChangeScene(string newSceneName) { }
/// <summary>
/// Called on the server when a scene is completed loaded, when the scene load was initiated by the server with ServerChangeScene().
/// </summary>
/// <param name="sceneName">The name of the new scene.</param>
public override void OnServerSceneChanged(string sceneName) { }
/// <summary>
/// Called from ClientChangeScene immediately before SceneManager.LoadSceneAsync is executed
/// <para>This allows client to do work / cleanup / prep before the scene changes.</para>
/// </summary>
/// <param name="newSceneName">Name of the scene that's about to be loaded</param>
/// <param name="sceneOperation">Scene operation that's about to happen</param>
/// <param name="customHandling">true to indicate that scene loading will be handled through overrides</param>
public override void OnClientChangeScene(string newSceneName, SceneOperation sceneOperation, bool customHandling) { }
/// <summary>
/// Called on clients when a scene has completed loaded, when the scene load was initiated by the server.
/// <para>Scene changes can cause player objects to be destroyed. The default implementation of OnClientSceneChanged in the NetworkManager is to add a player object for the connection if no player object exists.</para>
/// </summary>
public override void OnClientSceneChanged()
{
base.OnClientSceneChanged();
}
#endregion
#region Server System Callbacks
/// <summary>
/// Called on the server when a new client connects.
/// <para>Unity calls this on the Server when a Client connects to the Server. Use an override to tell the NetworkManager what to do when a client connects to the server.</para>
/// </summary>
/// <param name="conn">Connection from client.</param>
public override void OnServerConnect(NetworkConnectionToClient conn) { }
/// <summary>
/// Called on the server when a client is ready.
/// <para>The default implementation of this function calls NetworkServer.SetClientReady() to continue the network setup process.</para>
/// </summary>
/// <param name="conn">Connection from client.</param>
public override void OnServerReady(NetworkConnectionToClient conn)
{
base.OnServerReady(conn);
}
/// <summary>
/// Called on the server when a client adds a new player with ClientScene.AddPlayer.
/// <para>The default implementation for this function creates a new player object from the playerPrefab.</para>
/// </summary>
/// <param name="conn">Connection from client.</param>
public override void OnServerAddPlayer(NetworkConnectionToClient conn)
{
base.OnServerAddPlayer(conn);
}
/// <summary>
/// Called on the server when a client disconnects.
/// <para>This is called on the Server when a Client disconnects from the Server. Use an override to decide what should happen when a disconnection is detected.</para>
/// </summary>
/// <param name="conn">Connection from client.</param>
public override void OnServerDisconnect(NetworkConnectionToClient conn)
{
base.OnServerDisconnect(conn);
}
/// <summary>
/// Called on server when transport raises an error.
/// <para>NetworkConnection may be null.</para>
/// </summary>
/// <param name="conn">Connection of the client...may be null</param>
/// <param name="transportError">TransportError enum</param>
/// <param name="message">String message of the error.</param>
public override void OnServerError(NetworkConnectionToClient conn, TransportError transportError, string message) { }
/// <summary>
/// Called on server when transport raises an exception.
/// <para>NetworkConnection may be null.</para>
/// </summary>
/// <param name="conn">Connection of the client...may be null</param>
/// <param name="exception">Exception thrown from the Transport.</param>
public override void OnServerTransportException(NetworkConnectionToClient conn, Exception exception) { }
#endregion
#region Client System Callbacks
/// <summary>
/// Called on the client when connected to a server.
/// <para>The default implementation of this function sets the client as ready and adds a player. Override the function to dictate what happens when the client connects.</para>
/// </summary>
public override void OnClientConnect()
{
base.OnClientConnect();
}
/// <summary>
/// Called on clients when disconnected from a server.
/// <para>This is called on the client when it disconnects from the server. Override this function to decide what happens when the client disconnects.</para>
/// </summary>
public override void OnClientDisconnect() { }
/// <summary>
/// Called on clients when a servers tells the client it is no longer ready.
/// <para>This is commonly used when switching scenes.</para>
/// </summary>
public override void OnClientNotReady() { }
/// <summary>
/// Called on client when transport raises an error.</summary>
/// </summary>
/// <param name="transportError">TransportError enum.</param>
/// <param name="message">String message of the error.</param>
public override void OnClientError(TransportError transportError, string message) { }
/// <summary>
/// Called on client when transport raises an exception.</summary>
/// </summary>
/// <param name="exception">Exception thrown from the Transport.</param>
public override void OnClientTransportException(Exception exception) { }
#endregion
#region Start & Stop Callbacks
// Since there are multiple versions of StartServer, StartClient and StartHost, to reliably customize
// their functionality, users would need override all the versions. Instead these callbacks are invoked
// from all versions, so users only need to implement this one case.
/// <summary>
/// This is invoked when a host is started.
/// <para>StartHost has multiple signatures, but they all cause this hook to be called.</para>
/// </summary>
public override void OnStartHost() { }
/// <summary>
/// This is invoked when a server is started - including when a host is started.
/// <para>StartServer has multiple signatures, but they all cause this hook to be called.</para>
/// </summary>
public override void OnStartServer() { }
/// <summary>
/// This is invoked when the client is started.
/// </summary>
public override void OnStartClient() { }
/// <summary>
/// This is called when a host is stopped.
/// </summary>
public override void OnStopHost() { }
/// <summary>
/// This is called when a server is stopped - including when a host is stopped.
/// </summary>
public override void OnStopServer() { }
/// <summary>
/// This is called when a client is stopped.
/// </summary>
public override void OnStopClient() { }
#endregion
}
}

View File

@ -1,11 +1,11 @@
fileFormatVersion: 2
guid: e8f68561248aaca4fb96847ce24742ee
guid: bcc60dcfb35eb614dba363be60f12e68
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 4969918300bfa9a4a8c733975df74016
guid: 06335d3cc7f96354ea5f0f9602fb853e
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -0,0 +1,897 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 12
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 256
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 1
m_PVRDenoiserTypeDirect: 1
m_PVRDenoiserTypeIndirect: 1
m_PVRDenoiserTypeAO: 1
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_LightingSettings: {fileID: 0}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 3
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
buildHeightMesh: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &361955662
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 361955665}
- component: {fileID: 361955664}
- component: {fileID: 361955663}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &361955663
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 361955662}
m_Enabled: 1
--- !u!20 &361955664
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 361955662}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_Iso: 200
m_ShutterSpeed: 0.005
m_Aperture: 16
m_FocusDistance: 10
m_FocalLength: 50
m_BladeCount: 5
m_Curvature: {x: 2, y: 11}
m_BarrelClipping: 0.25
m_Anamorphism: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &361955665
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 361955662}
serializedVersion: 2
m_LocalRotation: {x: 0.08715574, y: -0, z: -0, w: 0.9961947}
m_LocalPosition: {x: 0, y: 4.08, z: -8}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &856494733
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 856494741}
- component: {fileID: 856494740}
- component: {fileID: 856494739}
- component: {fileID: 856494737}
- component: {fileID: 856494738}
- component: {fileID: 856494734}
- component: {fileID: 856494736}
- component: {fileID: 856494735}
m_Layer: 0
m_Name: Cube
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &856494734
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 856494733}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bf9fc8899cb57ff4faff8849692b109f, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 0
syncMode: 0
syncInterval: 0
rigidBody: {fileID: 856494737}
--- !u!114 &856494735
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 856494733}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8ff3ba0becae47b8b9381191598957c8, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 0
syncMode: 0
syncInterval: 0
target: {fileID: 856494741}
syncPosition: 1
syncRotation: 1
syncScale: 0
onlySyncOnChange: 1
compressRotation: 1
interpolatePosition: 1
interpolateRotation: 1
interpolateScale: 1
coordinateSpace: 0
sendIntervalMultiplier: 1
timelineOffset: 0
showGizmos: 0
showOverlay: 0
overlayColor: {r: 0, g: 0, b: 0, a: 0.5}
onlySyncOnChangeCorrectionMultiplier: 2
rotationSensitivity: 0.01
positionPrecision: 0.01
scalePrecision: 0.01
--- !u!114 &856494736
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 856494733}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9b91ecbcc199f4492b9a91e820070131, type: 3}
m_Name:
m_EditorClassIdentifier:
sceneId: 2306645459
_assetId: 0
serverOnly: 0
visibility: 0
hasSpawned: 0
--- !u!54 &856494737
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 856494733}
serializedVersion: 4
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_CenterOfMass: {x: 0, y: 0, z: 0}
m_InertiaTensor: {x: 1, y: 1, z: 1}
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_ImplicitCom: 1
m_ImplicitTensor: 1
m_UseGravity: 1
m_IsKinematic: 1
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!65 &856494738
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 856494733}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &856494739
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 856494733}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!33 &856494740
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 856494733}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &856494741
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 856494733}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 2, z: 20}
m_LocalScale: {x: 4, y: 4, z: 4}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &890531170
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 890531172}
- component: {fileID: 890531171}
m_Layer: 0
m_Name: Spawn
m_TagString: Untagged
m_Icon: {fileID: -964228994112308473, guid: 0000000000000000d000000000000000, type: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &890531171
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 890531170}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 41f84591ce72545258ea98cb7518d8b9, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &890531172
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 890531170}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0.38268343, z: 0, w: 0.92387956}
m_LocalPosition: {x: -14, y: 5, z: -14}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 45, z: 0}
--- !u!1 &980545347
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 980545349}
- component: {fileID: 980545348}
m_Layer: 0
m_Name: Spawn
m_TagString: Untagged
m_Icon: {fileID: -964228994112308473, guid: 0000000000000000d000000000000000, type: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &980545348
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 980545347}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 41f84591ce72545258ea98cb7518d8b9, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &980545349
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 980545347}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0.92387956, z: 0, w: 0.38268343}
m_LocalPosition: {x: -14, y: 5, z: 14}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 135, z: 0}
--- !u!1 &1175360880
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1175360882}
- component: {fileID: 1175360881}
m_Layer: 0
m_Name: Spawn
m_TagString: Untagged
m_Icon: {fileID: -964228994112308473, guid: 0000000000000000d000000000000000, type: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1175360881
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1175360880}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 41f84591ce72545258ea98cb7518d8b9, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &1175360882
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1175360880}
serializedVersion: 2
m_LocalRotation: {x: 0, y: -0.38268343, z: 0, w: 0.92387956}
m_LocalPosition: {x: 14, y: 5, z: -14}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: -45, z: 0}
--- !u!1001 &1267422303
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 7289113483685912224, guid: 8aa53535b8964fd4e985d4a620888b1d, type: 3}
propertyPath: m_LocalPosition.x
value: -500
objectReference: {fileID: 0}
- target: {fileID: 7289113483685912224, guid: 8aa53535b8964fd4e985d4a620888b1d, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7289113483685912224, guid: 8aa53535b8964fd4e985d4a620888b1d, type: 3}
propertyPath: m_LocalPosition.z
value: -500
objectReference: {fileID: 0}
- target: {fileID: 7289113483685912224, guid: 8aa53535b8964fd4e985d4a620888b1d, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7289113483685912224, guid: 8aa53535b8964fd4e985d4a620888b1d, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7289113483685912224, guid: 8aa53535b8964fd4e985d4a620888b1d, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7289113483685912224, guid: 8aa53535b8964fd4e985d4a620888b1d, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7289113483685912224, guid: 8aa53535b8964fd4e985d4a620888b1d, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7289113483685912224, guid: 8aa53535b8964fd4e985d4a620888b1d, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7289113483685912224, guid: 8aa53535b8964fd4e985d4a620888b1d, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7289113483685912227, guid: 8aa53535b8964fd4e985d4a620888b1d, type: 3}
propertyPath: m_Name
value: Terrain
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 8aa53535b8964fd4e985d4a620888b1d, type: 3}
--- !u!1 &1708370876
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1708370878}
- component: {fileID: 1708370877}
m_Layer: 0
m_Name: Spawn
m_TagString: Untagged
m_Icon: {fileID: -964228994112308473, guid: 0000000000000000d000000000000000, type: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1708370877
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1708370876}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 41f84591ce72545258ea98cb7518d8b9, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &1708370878
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1708370876}
serializedVersion: 2
m_LocalRotation: {x: 0, y: -0.92387956, z: 0, w: 0.38268343}
m_LocalPosition: {x: 14, y: 5, z: 14}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: -135, z: 0}
--- !u!1 &2078663351
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2078663353}
- component: {fileID: 2078663352}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &2078663352
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2078663351}
m_Enabled: 1
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 0.5
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 4
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_UseViewFrustumForShadowCasterCull: 1
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &2078663353
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2078663351}
serializedVersion: 2
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &2126814503
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2126814505}
- component: {fileID: 2126814507}
- component: {fileID: 2126814506}
- component: {fileID: 2126814504}
- component: {fileID: 2126814508}
m_Layer: 0
m_Name: Network
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &2126814504
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2126814503}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6b0fecffa3f624585964b0d0eb21b18e, type: 3}
m_Name:
m_EditorClassIdentifier:
port: 7777
DualMode: 1
NoDelay: 1
Interval: 10
Timeout: 10000
RecvBufferSize: 7361536
SendBufferSize: 7361536
FastResend: 2
ReceiveWindowSize: 4096
SendWindowSize: 4096
MaxRetransmit: 40
MaximizeSocketBuffers: 1
ReliableMaxMessageSize: 297433
UnreliableMaxMessageSize: 1194
debugLog: 0
statisticsGUI: 0
statisticsLog: 0
--- !u!4 &2126814505
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2126814503}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2126814506
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2126814503}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bcc60dcfb35eb614dba363be60f12e68, type: 3}
m_Name:
m_EditorClassIdentifier:
dontDestroyOnLoad: 0
runInBackground: 1
headlessStartMode: 1
editorAutoStart: 0
sendRate: 60
autoStartServerBuild: 0
autoConnectClientBuild: 0
offlineScene:
onlineScene:
transport: {fileID: 2126814504}
networkAddress: localhost
maxConnections: 100
disconnectInactiveConnections: 0
disconnectInactiveTimeout: 60
authenticator: {fileID: 0}
playerPrefab: {fileID: 7863680369626900553, guid: f9534c78c5208a04a993c69840315287, type: 3}
autoCreatePlayer: 1
playerSpawnMethod: 1
spawnPrefabs: []
exceptionsDisconnect: 1
snapshotSettings:
bufferTimeMultiplier: 2
bufferLimit: 32
catchupNegativeThreshold: -1
catchupPositiveThreshold: 1
catchupSpeed: 0.019999999552965164
slowdownSpeed: 0.03999999910593033
driftEmaDuration: 1
dynamicAdjustment: 1
dynamicAdjustmentTolerance: 1
deliveryTimeEmaDuration: 2
evaluationMethod: 0
evaluationInterval: 3
timeInterpolationGui: 0
--- !u!114 &2126814507
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2126814503}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6442dc8070ceb41f094e44de0bf87274, type: 3}
m_Name:
m_EditorClassIdentifier:
offsetX: 0
offsetY: 0
--- !u!114 &2126814508
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2126814503}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6635375fbc6be456ea640b75add6378e, type: 3}
m_Name:
m_EditorClassIdentifier:
showGUI: 1
showLog: 0
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0
m_Roots:
- {fileID: 361955665}
- {fileID: 2078663353}
- {fileID: 2126814505}
- {fileID: 1267422303}
- {fileID: 856494741}
- {fileID: 890531172}
- {fileID: 980545349}
- {fileID: 1175360882}
- {fileID: 1708370878}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2eee477bd391ecc4ba9ca46b6f8b86e3
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,22 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1953259897 &8574412962073106934
TerrainLayer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: BaseLayer
m_DiffuseTexture: {fileID: 10309, guid: 0000000000000000f000000000000000, type: 0}
m_NormalMapTexture: {fileID: 0}
m_MaskMapTexture: {fileID: 0}
m_TileSize: {x: 2, y: 2}
m_TileOffset: {x: 0, y: 0}
m_Specular: {r: 0, g: 0, b: 0, a: 0}
m_Metallic: 0
m_Smoothness: 0
m_NormalScale: 1
m_DiffuseRemapMin: {x: 0, y: 0, z: 0, w: 0}
m_DiffuseRemapMax: {x: 1, y: 1, z: 1, w: 1}
m_MaskMapRemapMin: {x: 0, y: 0, z: 0, w: 0}
m_MaskMapRemapMax: {x: 1, y: 1, z: 1, w: 1}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b9a3a9701c10ec044b88f3590e246054
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 8574412962073106934
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +1,8 @@
fileFormatVersion: 2
guid: e0dbc8b2f2711a54f9b7ed1358a4c6af
guid: 49ea6cc998ca79b449bff823dd956d4b
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 9100000
mainObjectFileID: 15600000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,549 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &7863680369626900553
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4659514702152478195}
- component: {fileID: 3560139896991457593}
- component: {fileID: 1584615235374487050}
- component: {fileID: 796067987244239294}
- component: {fileID: 6595414911156405995}
- component: {fileID: 943969255301123906}
- component: {fileID: 8662002890669114756}
- component: {fileID: 4362334322449175123}
- component: {fileID: 4076420439305423835}
- component: {fileID: 4696500281269712544}
- component: {fileID: 36696637711815440}
m_Layer: 0
m_Name: TankPrefab
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4659514702152478195
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 702109291309605218}
- {fileID: 8174595063106582951}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &3560139896991457593
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 71ac1e35462ffad469e77d1c2fe6c9f3, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 0
syncMode: 0
syncInterval: 0
offset: {x: 0, y: 7, z: -15}
rotation: {x: 15, y: 0, z: 0}
--- !u!143 &1584615235374487050
CharacterController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 0
serializedVersion: 3
m_Height: 2
m_Radius: 0.5
m_SlopeLimit: 45
m_StepOffset: 0.3
m_SkinWidth: 0.02
m_MinMoveDistance: 0
m_Center: {x: 0, y: 1, z: 0}
--- !u!54 &796067987244239294
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
serializedVersion: 4
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_CenterOfMass: {x: 0, y: 0, z: 0}
m_InertiaTensor: {x: 1, y: 1, z: 1}
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_ImplicitCom: 1
m_ImplicitTensor: 1
m_UseGravity: 1
m_IsKinematic: 1
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!114 &6595414911156405995
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9b91ecbcc199f4492b9a91e820070131, type: 3}
m_Name:
m_EditorClassIdentifier:
sceneId: 0
_assetId: 1824730033
serverOnly: 0
visibility: 0
hasSpawned: 0
--- !u!114 &943969255301123906
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8ff3ba0becae47b8b9381191598957c8, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 1
syncMode: 0
syncInterval: 0
target: {fileID: 4659514702152478195}
syncPosition: 1
syncRotation: 1
syncScale: 0
onlySyncOnChange: 1
compressRotation: 0
interpolatePosition: 1
interpolateRotation: 1
interpolateScale: 1
coordinateSpace: 0
sendIntervalMultiplier: 1
timelineOffset: 0
showGizmos: 0
showOverlay: 0
overlayColor: {r: 0, g: 0, b: 0, a: 0.5}
onlySyncOnChangeCorrectionMultiplier: 2
rotationSensitivity: 0.01
positionPrecision: 0.01
scalePrecision: 0.01
--- !u!114 &8662002890669114756
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8ff3ba0becae47b8b9381191598957c8, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 1
syncMode: 0
syncInterval: 0
target: {fileID: 702109291309605222}
syncPosition: 0
syncRotation: 1
syncScale: 0
onlySyncOnChange: 1
compressRotation: 0
interpolatePosition: 1
interpolateRotation: 1
interpolateScale: 1
coordinateSpace: 0
sendIntervalMultiplier: 1
timelineOffset: 0
showGizmos: 0
showOverlay: 0
overlayColor: {r: 0, g: 0, b: 0, a: 0.5}
onlySyncOnChangeCorrectionMultiplier: 2
rotationSensitivity: 0.01
positionPrecision: 0.01
scalePrecision: 0.01
--- !u!114 &4362334322449175123
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8ff3ba0becae47b8b9381191598957c8, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 1
syncMode: 0
syncInterval: 0
target: {fileID: 702109291309605224}
syncPosition: 0
syncRotation: 1
syncScale: 0
onlySyncOnChange: 1
compressRotation: 0
interpolatePosition: 1
interpolateRotation: 1
interpolateScale: 1
coordinateSpace: 0
sendIntervalMultiplier: 1
timelineOffset: 0
showGizmos: 0
showOverlay: 0
overlayColor: {r: 0, g: 0, b: 0, a: 0.5}
onlySyncOnChangeCorrectionMultiplier: 2
rotationSensitivity: 0.01
positionPrecision: 0.01
scalePrecision: 0.01
--- !u!114 &4076420439305423835
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 047024b2ae9afb74485837a482ea4175, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 0
syncMode: 0
syncInterval: 0
boxCollider: {fileID: 848258961126524234}
characterController: {fileID: 1584615235374487050}
tankNTR: {fileID: 943969255301123906}
ControllerUIPrefab: {fileID: 644766297742565710, guid: e64b14552402f6745a7f0aca6237fae2, type: 3}
moveKeys:
Forward: 119
Back: 115
TurnLeft: 97
TurnRight: 100
optionsKeys:
AutoRun: 114
ToggleUI: 117
controlOptions: 2
maxMoveSpeed: 5
inputSensitivity: 2
inputGravity: 2
maxTurnSpeed: 100
turnAcceleration: 3
groundState: 2
horizontal: 0
vertical: 0
turnSpeed: 0
animVelocity: 0
animRotation: 0
direction: {x: 0, y: 0, z: 0}
velocity: {x: 0, y: 0, z: 0}
controllerUI: {fileID: 0}
--- !u!114 &4696500281269712544
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2620edb022743ce4bafb12274ee78716, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 0
syncMode: 0
syncInterval: 0
TurretUIPrefab: {fileID: 644766297742565710, guid: 4d16730f7a8ba0a419530d1156d25080, type: 3}
projectilePrefab: {fileID: 5890560936853567077, guid: aec853915cd4f4477ba1532b5fe05488, type: 3}
animator: {fileID: 702109291319152264}
turretNTR: {fileID: 8662002890669114756}
barrelNTR: {fileID: 4362334322449175123}
turret: {fileID: 702109291309605222}
barrel: {fileID: 702109291309605224}
projectileMount: {fileID: 5863288529097842480}
playerObject: {fileID: 3185878892915811175}
playerColor:
serializedVersion: 2
rgba: 4278190080
moveKeys:
PitchUp: 273
PitchDown: 274
TurnLeft: 276
TurnRight: 275
otherKeys:
Shoot: 32
optionsKeys:
MouseLock: 109
AutoLevel: 108
ToggleUI: 117
controlOptions: 6
maxTurretSpeed: 250
turretAcceleration: 10
maxPitchSpeed: 30
maxPitchUpAngle: 25
maxPitchDownAngle: 0
pitchAcceleration: 3
mouseInputX: 0
mouseSensitivity: 10
turretSpeed: 0
pitchAngle: 0
pitchSpeed: 0
turretUI: {fileID: 0}
--- !u!114 &36696637711815440
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863680369626900553}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a98fd0a5ae4916d48bdcdb0e8c99a5cc, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 0
syncMode: 0
syncInterval: 0
healthBar: {fileID: 3566980308471553575}
maxHealth: 5
health: 5
respawn: 1
respawnTime: 3
--- !u!1 &9109672380512621037
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8174595063106582951}
- component: {fileID: 4153780752967283830}
- component: {fileID: 3566980308471553575}
- component: {fileID: 1151573331580713941}
m_Layer: 0
m_Name: HealthBar
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8174595063106582951
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9109672380512621037}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 4.2, z: 0}
m_LocalScale: {x: 0.1, y: 0.1, z: 0.1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4659514702152478195}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &4153780752967283830
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9109672380512621037}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10100, guid: 0000000000000000e000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!102 &3566980308471553575
TextMesh:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9109672380512621037}
m_Text: -----
m_OffsetZ: 0
m_CharacterSize: 1
m_LineSpacing: 1
m_Anchor: 4
m_Alignment: 1
m_TabSize: 4
m_FontSize: 100
m_FontStyle: 0
m_RichText: 1
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_Color:
serializedVersion: 2
rgba: 4278255360
--- !u!114 &1151573331580713941
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9109672380512621037}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: afa2d590c474413d9fc183551385ed85, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &4305764793209200135
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 4659514702152478195}
m_Modifications:
- target: {fileID: 3638700596990255941, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_Name
value: BasePrefab
objectReference: {fileID: 0}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalPosition.y
value: 0.05
objectReference: {fileID: 0}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
--- !u!4 &702109291309605218 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
m_PrefabInstance: {fileID: 4305764793209200135}
m_PrefabAsset: {fileID: 0}
--- !u!4 &702109291309605222 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 3638700596990361441, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
m_PrefabInstance: {fileID: 4305764793209200135}
m_PrefabAsset: {fileID: 0}
--- !u!4 &702109291309605224 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 3638700596990361455, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
m_PrefabInstance: {fileID: 4305764793209200135}
m_PrefabAsset: {fileID: 0}
--- !u!95 &702109291319152264 stripped
Animator:
m_CorrespondingSourceObject: {fileID: 3638700596980764815, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
m_PrefabInstance: {fileID: 4305764793209200135}
m_PrefabAsset: {fileID: 0}
--- !u!65 &848258961126524234 stripped
BoxCollider:
m_CorrespondingSourceObject: {fileID: 3460094114880756557, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
m_PrefabInstance: {fileID: 4305764793209200135}
m_PrefabAsset: {fileID: 0}
--- !u!1 &3185878892915811175 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1727031213358021984, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
m_PrefabInstance: {fileID: 4305764793209200135}
m_PrefabAsset: {fileID: 0}
--- !u!4 &5863288529097842480 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 7683056980803567927, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
m_PrefabInstance: {fileID: 4305764793209200135}
m_PrefabAsset: {fileID: 0}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f9534c78c5208a04a993c69840315287
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,80 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &7289113483685912227
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7289113483685912224}
- component: {fileID: 7289113483685912225}
- component: {fileID: 7289113483685912226}
m_Layer: 0
m_Name: Terrain
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 2147483647
m_IsActive: 1
--- !u!4 &7289113483685912224
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7289113483685912227}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -500, y: 0, z: -500}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!218 &7289113483685912225
Terrain:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7289113483685912227}
m_Enabled: 1
serializedVersion: 6
m_TerrainData: {fileID: 15600000, guid: 49ea6cc998ca79b449bff823dd956d4b, type: 2}
m_TreeDistance: 5000
m_TreeBillboardDistance: 50
m_TreeCrossFadeLength: 5
m_TreeMaximumFullLODCount: 50
m_DetailObjectDistance: 80
m_DetailObjectDensity: 1
m_HeightmapPixelError: 5
m_SplatMapDistance: 1000
m_HeightmapMaximumLOD: 0
m_ShadowCastingMode: 0
m_DrawHeightmap: 1
m_DrawInstanced: 0
m_DrawTreesAndFoliage: 1
m_StaticShadowCaster: 0
m_ReflectionProbeUsage: 0
m_MaterialTemplate: {fileID: 10652, guid: 0000000000000000f000000000000000, type: 0}
m_BakeLightProbesForTrees: 1
m_PreserveTreePrototypeLayers: 0
m_DeringLightProbesForTrees: 1
m_ScaleInLightmap: 0.0256
m_LightmapParameters: {fileID: 15203, guid: 0000000000000000f000000000000000, type: 0}
m_GroupingID: 0
m_RenderingLayerMask: 1
m_AllowAutoConnect: 1
--- !u!154 &7289113483685912226
TerrainCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7289113483685912227}
m_Material: {fileID: 0}
m_Enabled: 1
m_TerrainData: {fileID: 15600000, guid: 49ea6cc998ca79b449bff823dd956d4b, type: 2}
m_EnableTreeColliders: 1

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 8aa53535b8964fd4e985d4a620888b1d
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -25,12 +25,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1430875437483682}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0.39999998, z: 0.5}
m_LocalScale: {x: 0.5, y: 0.1, z: 0.2}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3138541494209382947}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &33190644788701022
MeshFilter:
@ -51,10 +52,12 @@ MeshRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 4294967295
m_RendererPriority: 0
m_Materials:
@ -79,6 +82,7 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &1480027675339556
GameObject:
m_ObjectHideFlags: 0
@ -111,13 +115,14 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1480027675339556}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 3138541494209382947}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &114402732107420660
MonoBehaviour:
@ -131,11 +136,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 9b91ecbcc199f4492b9a91e820070131, type: 3}
m_Name:
m_EditorClassIdentifier:
clientStarted: 0
sceneId: 0
_assetId: 2988185270
_assetId: 4096078365
serverOnly: 0
visible: 0
visibility: 0
hasSpawned: 0
--- !u!114 &485255742382306150
MonoBehaviour:
@ -156,6 +160,8 @@ MonoBehaviour:
syncPosition: 1
syncRotation: 1
syncScale: 0
onlySyncOnChange: 1
compressRotation: 1
interpolatePosition: 1
interpolateRotation: 1
interpolateScale: 0
@ -165,10 +171,8 @@ MonoBehaviour:
showGizmos: 0
showOverlay: 0
overlayColor: {r: 0, g: 0, b: 0, a: 0.5}
onlySyncOnChange: 1
onlySyncOnChangeCorrectionMultiplier: 2
rotationSensitivity: 0.01
compressRotation: 1
positionPrecision: 0.01
scalePrecision: 0.01
--- !u!114 &114892629901890886
@ -180,28 +184,48 @@ MonoBehaviour:
m_GameObject: {fileID: 1480027675339556}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 24fd13686a451ad498101a604d134e39, type: 3}
m_Script: {fileID: 11500000, guid: 9e212b6697536124ca0e7791fe5d8d6b, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 0
syncMode: 0
syncInterval: 0.1
syncInterval: 0
capsuleCollider: {fileID: 6799120071495980942}
characterController: {fileID: 143011667059871024}
moveSpeedMultiplier: 8
ControllerUIPrefab: {fileID: 644766297742565710, guid: 7beee247444994f0281dadde274cc4af, type: 3}
moveKeys:
Forward: 119
Back: 115
StrafeLeft: 97
StrafeRight: 100
TurnLeft: 113
TurnRight: 101
Jump: 32
optionsKeys:
MouseSteer: 109
AutoRun: 114
ToggleUI: 117
controlOptions: 4
maxMoveSpeed: 8
inputSensitivity: 2
inputGravity: 2
initialJumpSpeed: 2.5
maxJumpSpeed: 3.5
jumpAcceleration: 4
maxTurnSpeed: 100
turnDelta: 1
initialJumpSpeed: 0.2
maxJumpSpeed: 5
jumpDelta: 0.2
turnAcceleration: 3
groundState: 2
horizontal: 0
vertical: 0
mouseInputX: 0
mouseSensitivity: 0
turnSpeed: 0
jumpSpeed: 0
animVelocity: 0
animRotation: 0
velocity: {x: 0, y: 0, z: 0}
direction: {x: 0, y: 0, z: 0}
velocity: {x: 0, y: 0, z: 0}
controllerUI: {fileID: 0}
--- !u!114 &-6736841464767829722
MonoBehaviour:
m_ObjectHideFlags: 0
@ -217,6 +241,8 @@ MonoBehaviour:
syncDirection: 0
syncMode: 0
syncInterval: 0.1
offset: {x: 0, y: 3, z: -8}
rotation: {x: 10, y: 0, z: 0}
--- !u!114 &115187108610643062
MonoBehaviour:
m_ObjectHideFlags: 0
@ -242,8 +268,17 @@ CapsuleCollider:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1480027675339556}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Height: 2
m_Direction: 1
@ -256,9 +291,17 @@ CharacterController:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1480027675339556}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 0
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 0
serializedVersion: 3
m_Height: 2
m_Radius: 0.5
m_SlopeLimit: 45
@ -273,10 +316,21 @@ Rigidbody:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1480027675339556}
serializedVersion: 2
serializedVersion: 4
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_CenterOfMass: {x: 0, y: 0, z: 0}
m_InertiaTensor: {x: 1, y: 1, z: 1}
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_ImplicitCom: 1
m_ImplicitTensor: 1
m_UseGravity: 0
m_IsKinematic: 1
m_Interpolate: 0
@ -325,13 +379,14 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4926068573968176962}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4216737524944602}
m_Father: {fileID: 4822224316094678}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &1736510165009824269
MeshFilter:
@ -352,10 +407,12 @@ MeshRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
@ -380,3 +437,4 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}

View File

@ -1,187 +0,0 @@
using UnityEngine;
namespace Mirror.Examples.NetworkRoom
{
[AddComponentMenu("")]
[RequireComponent(typeof(CapsuleCollider))]
[RequireComponent(typeof(CharacterController))]
[RequireComponent(typeof(NetworkTransformReliable))]
[RequireComponent(typeof(Rigidbody))]
public class PlayerController : NetworkBehaviour
{
public enum GroundState : byte { Jumping, Falling, Grounded }
[Header("Avatar Components")]
public CharacterController characterController;
[Header("Movement")]
[Range(1, 20)]
public float moveSpeedMultiplier = 8f;
[Header("Turning")]
[Range(1f, 200f)]
public float maxTurnSpeed = 100f;
[Range(.5f, 5f)]
public float turnDelta = 3f;
[Header("Jumping")]
[Range(0.1f, 1f)]
public float initialJumpSpeed = 0.2f;
[Range(1f, 10f)]
public float maxJumpSpeed = 5f;
[Range(0.1f, 1f)]
public float jumpDelta = 0.2f;
[Header("Diagnostics")]
[ReadOnly, SerializeField] GroundState groundState = GroundState.Grounded;
[ReadOnly, SerializeField, Range(-1f, 1f)]
float horizontal;
[ReadOnly, SerializeField, Range(-1f, 1f)]
float vertical;
[ReadOnly, SerializeField, Range(-200f, 200f)]
float turnSpeed;
[ReadOnly, SerializeField, Range(-10f, 10f)]
float jumpSpeed;
[ReadOnly, SerializeField, Range(-1.5f, 1.5f)]
float animVelocity;
[ReadOnly, SerializeField, Range(-1.5f, 1.5f)]
float animRotation;
[ReadOnly, SerializeField] Vector3Int velocity;
[ReadOnly, SerializeField] Vector3 direction;
protected override void OnValidate()
{
base.OnValidate();
if (characterController == null)
characterController = GetComponent<CharacterController>();
// Override CharacterController default values
characterController.enabled = false;
characterController.skinWidth = 0.02f;
characterController.minMoveDistance = 0f;
GetComponent<Rigidbody>().isKinematic = true;
this.enabled = false;
}
public override void OnStartAuthority()
{
characterController.enabled = true;
this.enabled = true;
}
public override void OnStopAuthority()
{
this.enabled = false;
characterController.enabled = false;
}
void Update()
{
if (!characterController.enabled)
return;
HandleTurning();
HandleJumping();
HandleMove();
// Reset ground state
if (characterController.isGrounded)
groundState = GroundState.Grounded;
else if (groundState != GroundState.Jumping)
groundState = GroundState.Falling;
// Diagnostic velocity...FloorToInt for display purposes
velocity = Vector3Int.FloorToInt(characterController.velocity);
}
// TODO: Turning works while airborne...feature?
void HandleTurning()
{
// Q and E cancel each other out, reducing the turn to zero.
if (Input.GetKey(KeyCode.Q))
turnSpeed = Mathf.MoveTowards(turnSpeed, -maxTurnSpeed, turnDelta);
if (Input.GetKey(KeyCode.E))
turnSpeed = Mathf.MoveTowards(turnSpeed, maxTurnSpeed, turnDelta);
// If both pressed, reduce turning speed toward zero.
if (Input.GetKey(KeyCode.Q) && Input.GetKey(KeyCode.E))
turnSpeed = Mathf.MoveTowards(turnSpeed, 0, turnDelta);
// If neither pressed, reduce turning speed toward zero.
if (!Input.GetKey(KeyCode.Q) && !Input.GetKey(KeyCode.E))
turnSpeed = Mathf.MoveTowards(turnSpeed, 0, turnDelta);
transform.Rotate(0f, turnSpeed * Time.deltaTime, 0f);
}
void HandleJumping()
{
// Handle variable force jumping.
// Jump starts with initial power on takeoff, and jumps higher / longer
// as player holds spacebar. Jump power is increased by a diminishing amout
// every frame until it reaches maxJumpSpeed, or player releases the spacebar,
// and then changes to the falling state until it gets grounded.
if (groundState != GroundState.Falling && Input.GetKey(KeyCode.Space))
{
if (groundState != GroundState.Jumping)
{
// Start jump at initial power.
groundState = GroundState.Jumping;
jumpSpeed = initialJumpSpeed;
}
else
// Jumping has already started...increase power toward maxJumpSpeed over time.
jumpSpeed = Mathf.MoveTowards(jumpSpeed, maxJumpSpeed, jumpDelta);
// If power has reached maxJumpSpeed, change to falling until grounded.
// This prevents over-applying jump power while already in the air.
if (jumpSpeed == maxJumpSpeed)
groundState = GroundState.Falling;
}
else if (groundState != GroundState.Grounded)
{
// handles running off a cliff and/or player released Spacebar.
groundState = GroundState.Falling;
jumpSpeed = Mathf.Min(jumpSpeed, maxJumpSpeed);
jumpSpeed += Physics.gravity.y * Time.deltaTime;
}
else
jumpSpeed = Physics.gravity.y * Time.deltaTime;
}
// TODO: Directional input works while airborne...feature?
void HandleMove()
{
// Capture inputs
horizontal = Input.GetAxis("Horizontal");
vertical = Input.GetAxis("Vertical");
// Create initial direction vector without jumpSpeed (y-axis).
direction = new Vector3(horizontal, 0f, vertical);
// Clamp so diagonal strafing isn't a speed advantage.
direction = Vector3.ClampMagnitude(direction, 1f);
// Transforms direction from local space to world space.
direction = transform.TransformDirection(direction);
// Multiply for desired ground speed.
direction *= moveSpeedMultiplier;
// Add jumpSpeed to direction as last step.
direction.y = jumpSpeed;
// Finally move the character.
characterController.Move(direction * Time.deltaTime);
}
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6e1ca9a4688eb4b47830f13fc254c02c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -38,7 +38,6 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
@ -98,32 +97,75 @@ LightmapSettings:
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_LightingSettings: {fileID: 4890085278179872738, guid: 1cb229a9b0b434acf9cb6b263057a2a0,
type: 2}
m_LightingSettings: {fileID: 4890085278179872738, guid: 322f3038e3ebf7d4b82140ec43ed0391, type: 2}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
serializedVersion: 3
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentRadius: 2
agentHeight: 3
agentSlope: 45
agentClimb: 0.4
agentClimb: 2
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
cellSize: 0.6666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
buildHeightMesh: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 23800000, guid: 0bc607fa2e315482ebe98797e844e11f, type: 2}
m_NavMeshData: {fileID: 23800000, guid: 62bf79eb2260c8a48b7ef512f7e2c0e3, type: 2}
--- !u!1 &12226146
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 12226147}
- component: {fileID: 12226148}
m_Layer: 0
m_Name: SpawnPos
m_TagString: Untagged
m_Icon: {fileID: -964228994112308473, guid: 0000000000000000d000000000000000, type: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &12226147
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 12226146}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0.38268343, z: 0, w: 0.92387956}
m_LocalPosition: {x: -14, y: 2, z: -14}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4239341309712137294}
m_LocalEulerAnglesHint: {x: 0, y: 45, z: 0}
--- !u!114 &12226148
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 12226146}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 41f84591ce72545258ea98cb7518d8b9, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &88936773
GameObject:
m_ObjectHideFlags: 0
@ -156,9 +198,17 @@ Camera:
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_Iso: 200
m_ShutterSpeed: 0.005
m_Aperture: 16
m_FocusDistance: 10
m_FocalLength: 50
m_BladeCount: 5
m_Curvature: {x: 2, y: 11}
m_BarrelClipping: 0.25
m_Anamorphism: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
@ -192,14 +242,14 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 88936773}
m_LocalRotation: {x: 0, y: 0.92387956, z: -0.38268343, w: 0}
m_LocalPosition: {x: 0, y: 6.5, z: 8}
serializedVersion: 2
m_LocalRotation: {x: 0.3420201, y: 0, z: 0, w: 0.9396927}
m_LocalPosition: {x: 0, y: 20, z: -30}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 45, y: 180, z: 0}
m_LocalEulerAnglesHint: {x: 40, y: 0, z: 0}
--- !u!114 &88936778
MonoBehaviour:
m_ObjectHideFlags: 0
@ -213,8 +263,98 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
height: 150
offsetY: 40
maxLogCount: 50
showInEditor: 0
hotKey: 293
--- !u!1 &386825728
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 386825729}
- component: {fileID: 386825730}
m_Layer: 0
m_Name: SpawnPos
m_TagString: Untagged
m_Icon: {fileID: -964228994112308473, guid: 0000000000000000d000000000000000, type: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &386825729
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 386825728}
serializedVersion: 2
m_LocalRotation: {x: 0, y: -0.38268343, z: 0, w: 0.92387956}
m_LocalPosition: {x: 14, y: 2, z: -14}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4239341309712137294}
m_LocalEulerAnglesHint: {x: 0, y: -45, z: 0}
--- !u!114 &386825730
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 386825728}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 41f84591ce72545258ea98cb7518d8b9, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &781619875
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 781619876}
- component: {fileID: 781619877}
m_Layer: 0
m_Name: SpawnPos
m_TagString: Untagged
m_Icon: {fileID: -964228994112308473, guid: 0000000000000000d000000000000000, type: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &781619876
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 781619875}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0.92387956, z: 0, w: 0.38268343}
m_LocalPosition: {x: -14, y: 2, z: 14}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4239341309712137294}
m_LocalEulerAnglesHint: {x: 0, y: 135, z: 0}
--- !u!114 &781619877
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 781619875}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 41f84591ce72545258ea98cb7518d8b9, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1107091652
GameObject:
m_ObjectHideFlags: 0
@ -227,6 +367,10 @@ GameObject:
- component: {fileID: 1107091655}
- component: {fileID: 1107091654}
- component: {fileID: 1107091653}
- component: {fileID: 1107091660}
- component: {fileID: 1107091659}
- component: {fileID: 1107091658}
- component: {fileID: 1107091657}
m_Layer: 0
m_Name: Ground
m_TagString: Untagged
@ -284,9 +428,17 @@ MeshCollider:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1107091652}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 4
serializedVersion: 5
m_Convex: 0
m_CookingOptions: 30
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
@ -305,14 +457,98 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1107091652}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 4, y: 1, z: 4}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!65 &1107091657
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1107091652}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Size: {x: 10, y: 8, z: 0.1}
m_Center: {x: 0, y: 4, z: -5}
--- !u!65 &1107091658
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1107091652}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Size: {x: 10, y: 8, z: 0.1}
m_Center: {x: 0, y: 4, z: 5}
--- !u!65 &1107091659
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1107091652}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Size: {x: 0.1, y: 8, z: 10}
m_Center: {x: 5, y: 4, z: 0}
--- !u!65 &1107091660
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1107091652}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Size: {x: 0.1, y: 8, z: 10}
m_Center: {x: -5, y: 4, z: 0}
--- !u!1 &1111626353
GameObject:
m_ObjectHideFlags: 0
@ -344,7 +580,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1324361701}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@ -436,7 +671,6 @@ RectTransform:
m_Children:
- {fileID: 1111626354}
m_Father: {fileID: 1691128381}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5}
@ -557,7 +791,9 @@ Canvas:
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_VertexColorAlwaysGammaSpace: 0
m_AdditionalShaderChannelsFlag: 0
m_UpdateRectTransformForStandalone: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
@ -575,27 +811,67 @@ RectTransform:
m_Children:
- {fileID: 1324361701}
m_Father: {fileID: 0}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!1 &1695890598
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1695890599}
- component: {fileID: 1695890600}
m_Layer: 0
m_Name: SpawnPos
m_TagString: Untagged
m_Icon: {fileID: -964228994112308473, guid: 0000000000000000d000000000000000, type: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1695890599
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1695890598}
serializedVersion: 2
m_LocalRotation: {x: 0, y: -0.92387956, z: 0, w: 0.38268343}
m_LocalPosition: {x: 14, y: 2, z: 14}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4239341309712137294}
m_LocalEulerAnglesHint: {x: 0, y: -135, z: 0}
--- !u!114 &1695890600
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1695890598}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 41f84591ce72545258ea98cb7518d8b9, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &1997245513
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 160176456, guid: d502982feecd043d8bfc6a5c64cd09f9, type: 3}
propertyPath: m_RootOrder
value: 9
objectReference: {fileID: 0}
- target: {fileID: 160176456, guid: d502982feecd043d8bfc6a5c64cd09f9, type: 3}
propertyPath: m_LocalPosition.x
value: 1.79
value: 8
objectReference: {fileID: 0}
- target: {fileID: 160176456, guid: d502982feecd043d8bfc6a5c64cd09f9, type: 3}
propertyPath: m_LocalPosition.y
@ -603,7 +879,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 160176456, guid: d502982feecd043d8bfc6a5c64cd09f9, type: 3}
propertyPath: m_LocalPosition.z
value: 1.22
value: 0
objectReference: {fileID: 0}
- target: {fileID: 160176456, guid: d502982feecd043d8bfc6a5c64cd09f9, type: 3}
propertyPath: m_LocalRotation.w
@ -641,7 +917,14 @@ PrefabInstance:
propertyPath: sceneId
value: 2401096628
objectReference: {fileID: 0}
- target: {fileID: 275309355690048611, guid: d502982feecd043d8bfc6a5c64cd09f9, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: d502982feecd043d8bfc6a5c64cd09f9, type: 3}
--- !u!1 &2054208274
GameObject:
@ -729,13 +1012,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2054208274}
serializedVersion: 2
m_LocalRotation: {x: 0.10938167, y: 0.8754261, z: -0.40821788, w: 0.23456976}
m_LocalPosition: {x: 0, y: 10, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 50, y: 150, z: 0}
--- !u!114 &2816348668128435076
MonoBehaviour:
@ -762,7 +1045,7 @@ MonoBehaviour:
MaxRetransmit: 40
MaximizeSocketBuffers: 1
ReliableMaxMessageSize: 297433
UnreliableMaxMessageSize: 1195
UnreliableMaxMessageSize: 1194
debugLog: 0
statisticsGUI: 0
statisticsLog: 0
@ -778,11 +1061,13 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 428012adc920d443cb0663d2dcb7ce02, type: 3}
m_Name:
m_EditorClassIdentifier:
dontDestroyOnLoad: 1
dontDestroyOnLoad: 0
runInBackground: 1
autoStartServerBuild: 1
autoConnectClientBuild: 0
headlessStartMode: 1
editorAutoStart: 0
sendRate: 60
autoStartServerBuild: 0
autoConnectClientBuild: 0
offlineScene:
onlineScene:
transport: {fileID: 2816348668128435076}
@ -791,12 +1076,11 @@ MonoBehaviour:
disconnectInactiveConnections: 0
disconnectInactiveTimeout: 60
authenticator: {fileID: 0}
playerPrefab: {fileID: 8872462076811691049, guid: ed5ad50f0736c40f28c9ffc195b0a5f5,
type: 3}
playerPrefab: {fileID: 8872462076811691049, guid: ed5ad50f0736c40f28c9ffc195b0a5f5, type: 3}
autoCreatePlayer: 1
playerSpawnMethod: 0
spawnPrefabs:
- {fileID: 5890560936853567077, guid: aec853915cd4f4477ba1532b5fe05488, type: 3}
playerSpawnMethod: 1
spawnPrefabs: []
exceptionsDisconnect: 1
snapshotSettings:
bufferTimeMultiplier: 2
bufferLimit: 32
@ -808,7 +1092,8 @@ MonoBehaviour:
dynamicAdjustment: 1
dynamicAdjustmentTolerance: 1
deliveryTimeEmaDuration: 2
connectionQualityInterval: 3
evaluationMethod: 0
evaluationInterval: 3
timeInterpolationGui: 0
--- !u!114 &2816348668128435078
MonoBehaviour:
@ -850,233 +1135,14 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2816348668128435081}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2849346197134948928
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2849346197134948952}
- component: {fileID: 2849346197134948932}
- component: {fileID: 2849346197134948931}
- component: {fileID: 2849346197134948930}
- component: {fileID: 2849346197134948929}
m_Layer: 0
m_Name: Quad
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
m_IsActive: 1
--- !u!65 &2849346197134948929
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2849346197134948928}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 0.01, z: 3}
m_Center: {x: 0, y: -0.5, z: -1.5}
--- !u!65 &2849346197134948930
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2849346197134948928}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 0.01, z: 3}
m_Center: {x: 0, y: 0.5, z: -1.5}
--- !u!65 &2849346197134948931
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2849346197134948928}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 0.01, y: 1, z: 3}
m_Center: {x: 0.5, y: 0, z: -1.5}
--- !u!65 &2849346197134948932
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2849346197134948928}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 0.01, y: 1, z: 3}
m_Center: {x: -0.5, y: 0, z: -1.5}
--- !u!4 &2849346197134948952
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2849346197134948928}
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 9.863444, y: 9.863444, z: 0.19726889}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
--- !u!1 &4239341308390436545
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4239341308390436546}
- component: {fileID: 4239341308390436547}
m_Layer: 0
m_Name: StartPos
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
m_IsActive: 1
--- !u!4 &4239341308390436546
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4239341308390436545}
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
m_LocalPosition: {x: 0, y: 1, z: 3}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4239341309712137294}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
--- !u!114 &4239341308390436547
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4239341308390436545}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 41f84591ce72545258ea98cb7518d8b9, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &4239341308987619385
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4239341308987619386}
- component: {fileID: 4239341308987619387}
m_Layer: 0
m_Name: StartPos
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
m_IsActive: 1
--- !u!4 &4239341308987619386
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4239341308987619385}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -3}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4239341309712137294}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &4239341308987619387
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4239341308987619385}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 41f84591ce72545258ea98cb7518d8b9, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &4239341309125333740
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4239341309125333741}
- component: {fileID: 4239341309125333742}
m_Layer: 0
m_Name: StartPos
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
m_IsActive: 1
--- !u!4 &4239341309125333741
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4239341309125333740}
m_LocalRotation: {x: 0, y: 0.7071068, z: -0, w: -0.7071068}
m_LocalPosition: {x: 3, y: 1, z: -0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4239341309712137294}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 270, z: 0}
--- !u!114 &4239341309125333742
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4239341309125333740}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 41f84591ce72545258ea98cb7518d8b9, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &4239341309712137293
GameObject:
m_ObjectHideFlags: 0
@ -1100,62 +1166,18 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4239341309712137293}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4239341308390436546}
- {fileID: 4239341310108531884}
- {fileID: 4239341309125333741}
- {fileID: 4239341308987619386}
- {fileID: 1695890599}
- {fileID: 386825729}
- {fileID: 781619876}
- {fileID: 12226147}
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &4239341310108531883
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4239341310108531884}
- component: {fileID: 4239341310108531885}
m_Layer: 0
m_Name: StartPos
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
m_IsActive: 1
--- !u!4 &4239341310108531884
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4239341310108531883}
m_LocalRotation: {x: 0, y: 0.7071068, z: 0, w: 0.7071068}
m_LocalPosition: {x: -3, y: 1, z: -0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4239341309712137294}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0}
--- !u!114 &4239341310108531885
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4239341310108531883}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 41f84591ce72545258ea98cb7518d8b9, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &5746453777584925833
Transform:
m_ObjectHideFlags: 0
@ -1163,13 +1185,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5746453777584925836}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &5746453777584925834
MonoBehaviour:
@ -1229,15 +1251,12 @@ PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 160176456, guid: d502982feecd043d8bfc6a5c64cd09f9, type: 3}
propertyPath: m_RootOrder
value: 8
objectReference: {fileID: 0}
- target: {fileID: 160176456, guid: d502982feecd043d8bfc6a5c64cd09f9, type: 3}
propertyPath: m_LocalPosition.x
value: -1.09
value: -8
objectReference: {fileID: 0}
- target: {fileID: 160176456, guid: d502982feecd043d8bfc6a5c64cd09f9, type: 3}
propertyPath: m_LocalPosition.y
@ -1245,7 +1264,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 160176456, guid: d502982feecd043d8bfc6a5c64cd09f9, type: 3}
propertyPath: m_LocalPosition.z
value: -0.89
value: 0
objectReference: {fileID: 0}
- target: {fileID: 160176456, guid: d502982feecd043d8bfc6a5c64cd09f9, type: 3}
propertyPath: m_LocalRotation.w
@ -1284,4 +1303,20 @@ PrefabInstance:
value: 2890115873
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: d502982feecd043d8bfc6a5c64cd09f9, type: 3}
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0
m_Roots:
- {fileID: 5746453777584925833}
- {fileID: 88936777}
- {fileID: 2054208276}
- {fileID: 2816348668128435083}
- {fileID: 1107091656}
- {fileID: 4239341309712137294}
- {fileID: 1691128381}
- {fileID: 8654251058949446163}
- {fileID: 1997245513}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 62bf79eb2260c8a48b7ef512f7e2c0e3
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 23800000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,66 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!850595691 &4890085278179872738
LightingSettings:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: MirrorTankTheftAutoSettings
serializedVersion: 6
m_GIWorkflowMode: 1
m_EnableBakedLightmaps: 0
m_EnableRealtimeLightmaps: 0
m_RealtimeEnvironmentLighting: 1
m_BounceScale: 1
m_AlbedoBoost: 1
m_IndirectOutputScale: 1
m_UsingShadowmask: 1
m_BakeBackend: 0
m_LightmapMaxSize: 1024
m_BakeResolution: 40
m_Padding: 2
m_LightmapCompression: 3
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAO: 0
m_MixedBakeMode: 2
m_LightmapsBakeMode: 1
m_FilterMode: 1
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_RealtimeResolution: 2
m_ForceWhiteAlbedo: 0
m_ForceUpdates: 0
m_FinalGather: 0
m_FinalGatherRayCount: 256
m_FinalGatherFiltering: 1
m_PVRCulling: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVREnvironmentSampleCount: 512
m_PVREnvironmentReferencePointCount: 2048
m_LightProbeSampleCountMultiplier: 4
m_PVRBounces: 2
m_PVRMinBounces: 2
m_PVREnvironmentImportanceSampling: 0
m_PVRFilteringMode: 2
m_PVRDenoiserTypeDirect: 0
m_PVRDenoiserTypeIndirect: 0
m_PVRDenoiserTypeAO: 0
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_PVRTiledBaking: 0
m_NumRaysToShootPerTexel: -1
m_RespectSceneVisibilityWhenBakingGI: 0

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 322f3038e3ebf7d4b82140ec43ed0391
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 4890085278179872738
userData:
assetBundleName:
assetBundleVariant:

View File

@ -11,7 +11,7 @@ GameObject:
- component: {fileID: 9057824595171805708}
- component: {fileID: 662729490405160656}
- component: {fileID: 3624570427921084598}
m_Layer: 8
m_Layer: 0
m_Name: Capsule
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -95,7 +95,7 @@ GameObject:
- component: {fileID: 3254954141432383832}
- component: {fileID: 1800893346221236401}
- component: {fileID: 136369082707552984}
m_Layer: 8
m_Layer: 0
m_Name: Visor
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -177,8 +177,8 @@ GameObject:
m_Component:
- component: {fileID: 5328458565928408179}
- component: {fileID: 8537344390966522168}
- component: {fileID: 887491563423388292}
- component: {fileID: 8993127209816276930}
- component: {fileID: 4357343043493134785}
- component: {fileID: 1143206540915927667}
- component: {fileID: 3175779197224890082}
- component: {fileID: -4781897372705814228}
@ -201,7 +201,7 @@ Transform:
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1.08, z: 0}
m_LocalScale: {x: 0.2, y: 0.2, z: 0.2}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 9057824595171805708}
@ -224,41 +224,6 @@ MonoBehaviour:
serverOnly: 0
visibility: 0
hasSpawned: 0
--- !u!114 &887491563423388292
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8872462076811691049}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a553cb17010b2403e8523b558bffbc14, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 1
syncMode: 0
syncInterval: 0
target: {fileID: 5328458565928408179}
syncPosition: 1
syncRotation: 1
syncScale: 0
onlySyncOnChange: 1
compressRotation: 1
interpolatePosition: 1
interpolateRotation: 1
interpolateScale: 0
coordinateSpace: 0
sendIntervalMultiplier: 3
timelineOffset: 1
showGizmos: 0
showOverlay: 0
overlayColor: {r: 0, g: 0, b: 0, a: 0.5}
bufferResetMultiplier: 5
changedDetection: 1
positionSensitivity: 0.01
rotationSensitivity: 0.01
scaleSensitivity: 0.01
--- !u!143 &8993127209816276930
CharacterController:
m_ObjectHideFlags: 0
@ -285,6 +250,40 @@ CharacterController:
m_SkinWidth: 0.02
m_MinMoveDistance: 0
m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &4357343043493134785
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8872462076811691049}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8ff3ba0becae47b8b9381191598957c8, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 1
syncMode: 0
syncInterval: 0
target: {fileID: 5328458565928408179}
syncPosition: 1
syncRotation: 1
syncScale: 0
onlySyncOnChange: 1
compressRotation: 1
interpolatePosition: 1
interpolateRotation: 1
interpolateScale: 1
coordinateSpace: 0
sendIntervalMultiplier: 1
timelineOffset: 0
showGizmos: 0
showOverlay: 0
overlayColor: {r: 0, g: 0, b: 0, a: 0.5}
onlySyncOnChangeCorrectionMultiplier: 2
rotationSensitivity: 0.01
positionPrecision: 0.01
scalePrecision: 0.01
--- !u!136 &1143206540915927667
CapsuleCollider:
m_ObjectHideFlags: 0
@ -350,6 +349,8 @@ MonoBehaviour:
syncDirection: 0
syncMode: 0
syncInterval: 0
offset: {x: 0, y: 3, z: -8}
rotation: {x: 10, y: 0, z: 0}
--- !u!114 &-1122083471338389313
MonoBehaviour:
m_ObjectHideFlags: 0
@ -377,27 +378,44 @@ MonoBehaviour:
m_GameObject: {fileID: 8872462076811691049}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ecf6aabfdda1548f69448ba0e306af4f, type: 3}
m_Script: {fileID: 11500000, guid: 9e212b6697536124ca0e7791fe5d8d6b, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 0
syncMode: 0
syncInterval: 0
characterController: {fileID: 8993127209816276930}
moveSpeedMultiplier: 2
ControllerUIPrefab: {fileID: 644766297742565710, guid: 7beee247444994f0281dadde274cc4af, type: 3}
moveKeys:
Forward: 119
Back: 115
StrafeLeft: 97
StrafeRight: 100
TurnLeft: 113
TurnRight: 101
Jump: 32
optionsKeys:
MouseSteer: 109
AutoRun: 114
ToggleUI: 117
controlOptions: 4
maxMoveSpeed: 8
inputSensitivity: 2
inputGravity: 2
initialJumpSpeed: 2.5
maxJumpSpeed: 3.5
jumpAcceleration: 4
maxTurnSpeed: 100
turnDelta: 1
initialJumpSpeed: 0.2
maxJumpSpeed: 2
jumpDelta: 0.2
turnAcceleration: 3
groundState: 2
horizontal: 0
vertical: 0
mouseInputX: 0
mouseSensitivity: 0.01
turnSpeed: 0
jumpSpeed: 0
animVelocity: 0
animRotation: 0
velocity: {x: 0, y: 0, z: 0}
direction: {x: 0, y: 0, z: 0}
tankController: {fileID: 0}
canControlPlayer: 1
velocity: {x: 0, y: 0, z: 0}
controllerUI: {fileID: 0}

File diff suppressed because it is too large Load Diff

View File

@ -1,30 +0,0 @@
using System.Linq;
using UnityEngine;
namespace Mirror.Examples.TankTheftAuto
{
[AddComponentMenu("")]
public class AuthorityNetworkManager : NetworkManager
{
/// <summary>
/// Called on the server when a client disconnects.
/// <para>This is called on the Server when a Client disconnects from the Server. Use an override to decide what should happen when a disconnection is detected.</para>
/// </summary>
/// <param name="conn">Connection from client.</param>
public override void OnServerDisconnect(NetworkConnectionToClient conn)
{
// this code is to reset any objects belonging to disconnected clients
// make a copy because the original collection will change in the loop
NetworkIdentity[] copyOfOwnedObjects = conn.owned.ToArray();
// Loop the copy, skipping the player object.
// RemoveClientAuthority on everything else
foreach (NetworkIdentity identity in copyOfOwnedObjects)
{
if (identity != conn.identity)
identity.RemoveClientAuthority();
}
base.OnServerDisconnect(conn);
}
}
}

View File

@ -1,292 +0,0 @@
using UnityEngine;
namespace Mirror.Examples.TankTheftAuto
{
[RequireComponent(typeof(CapsuleCollider))]
[RequireComponent(typeof(CharacterController))]
[RequireComponent(typeof(NetworkTransformUnreliable))]
[RequireComponent(typeof(Rigidbody))]
public class PlayerController : NetworkBehaviour
{
public enum GroundState : byte { Jumping, Falling, Grounded }
[Header("Avatar Components")]
public CharacterController characterController;
[Header("Movement")]
[Range(1, 20)]
public float moveSpeedMultiplier = 8f;
[Header("Turning")]
[Range(1f, 200f)]
public float maxTurnSpeed = 100f;
[Range(.5f, 5f)]
public float turnDelta = 3f;
[Header("Jumping")]
[Range(0.1f, 1f)]
public float initialJumpSpeed = 0.2f;
[Range(1f, 10f)]
public float maxJumpSpeed = 5f;
[Range(0.1f, 1f)]
public float jumpDelta = 0.2f;
[Header("Diagnostics")]
[ReadOnly, SerializeField] GroundState groundState = GroundState.Grounded;
[ReadOnly, SerializeField, Range(-1f, 1f)]
float horizontal;
[ReadOnly, SerializeField, Range(-1f, 1f)]
float vertical;
[ReadOnly, SerializeField, Range(-200f, 200f)]
float turnSpeed;
[ReadOnly, SerializeField, Range(-10f, 10f)]
float jumpSpeed;
[ReadOnly, SerializeField, Range(-1.5f, 1.5f)]
float animVelocity;
[ReadOnly, SerializeField, Range(-1.5f, 1.5f)]
float animRotation;
[ReadOnly, SerializeField] Vector3Int velocity;
[ReadOnly, SerializeField] Vector3 direction;
protected override void OnValidate()
{
base.OnValidate();
if (characterController == null)
characterController = GetComponent<CharacterController>();
// Override CharacterController default values
characterController.enabled = false;
characterController.skinWidth = 0.02f;
characterController.minMoveDistance = 0f;
GetComponent<Rigidbody>().isKinematic = true;
this.enabled = false;
}
public override void OnStartAuthority()
{
characterController.enabled = true;
this.enabled = true;
}
public override void OnStopAuthority()
{
this.enabled = false;
characterController.enabled = false;
}
void Update()
{
if (!characterController.enabled)
return;
// we need to detect player exiting vehichle, so input detection is not blockeed
HandleInput();
if (!canControlPlayer)
return;
HandleTurning();
HandleJumping();
HandleMove();
// Reset ground state
if (characterController.isGrounded)
groundState = GroundState.Grounded;
else if (groundState != GroundState.Jumping)
groundState = GroundState.Falling;
// Diagnostic velocity...FloorToInt for display purposes
velocity = Vector3Int.FloorToInt(characterController.velocity);
}
// TODO: Turning works while airborne...feature?
void HandleTurning()
{
// Q and E cancel each other out, reducing the turn to zero.
if (Input.GetKey(KeyCode.Q))
turnSpeed = Mathf.MoveTowards(turnSpeed, -maxTurnSpeed, turnDelta);
if (Input.GetKey(KeyCode.E))
turnSpeed = Mathf.MoveTowards(turnSpeed, maxTurnSpeed, turnDelta);
// If both pressed, reduce turning speed toward zero.
if (Input.GetKey(KeyCode.Q) && Input.GetKey(KeyCode.E))
turnSpeed = Mathf.MoveTowards(turnSpeed, 0, turnDelta);
// If neither pressed, reduce turning speed toward zero.
if (!Input.GetKey(KeyCode.Q) && !Input.GetKey(KeyCode.E))
turnSpeed = Mathf.MoveTowards(turnSpeed, 0, turnDelta);
transform.Rotate(0f, turnSpeed * Time.deltaTime, 0f);
}
void HandleJumping()
{
// Handle variable force jumping.
// Jump starts with initial power on takeoff, and jumps higher / longer
// as player holds spacebar. Jump power is increased by a diminishing amout
// every frame until it reaches maxJumpSpeed, or player releases the spacebar,
// and then changes to the falling state until it gets grounded.
if (groundState != GroundState.Falling && Input.GetKey(KeyCode.Space))
{
if (groundState != GroundState.Jumping)
{
// Start jump at initial power.
groundState = GroundState.Jumping;
jumpSpeed = initialJumpSpeed;
}
else
// Jumping has already started...increase power toward maxJumpSpeed over time.
jumpSpeed = Mathf.MoveTowards(jumpSpeed, maxJumpSpeed, jumpDelta);
// If power has reached maxJumpSpeed, change to falling until grounded.
// This prevents over-applying jump power while already in the air.
if (jumpSpeed == maxJumpSpeed)
groundState = GroundState.Falling;
}
else if (groundState != GroundState.Grounded)
{
// handles running off a cliff and/or player released Spacebar.
groundState = GroundState.Falling;
jumpSpeed = Mathf.Min(jumpSpeed, maxJumpSpeed);
jumpSpeed += Physics.gravity.y * Time.deltaTime;
}
else
jumpSpeed = Physics.gravity.y * Time.deltaTime;
}
// TODO: Directional input works while airborne...feature?
void HandleMove()
{
// Capture inputs
horizontal = Input.GetAxis("Horizontal");
vertical = Input.GetAxis("Vertical");
// Create initial direction vector without jumpSpeed (y-axis).
direction = new Vector3(horizontal, 0f, vertical);
// Clamp so diagonal strafing isn't a speed advantage.
direction = Vector3.ClampMagnitude(direction, 1f);
// Transforms direction from local space to world space.
direction = transform.TransformDirection(direction);
// Multiply for desired ground speed.
direction *= moveSpeedMultiplier;
// Add jumpSpeed to direction as last step.
direction.y = jumpSpeed;
// Finally move the character.
characterController.Move(direction * Time.deltaTime);
}
public TankController tankController;
// we dont want this object to move once you have control of tank
public bool canControlPlayer = true;
void HandleInput()
{
if (tankController)
{
// if no one owns trigger object
if (canControlPlayer && tankController.objectOwner == null)
{
if (Input.GetKeyDown(KeyCode.E))
{
CmdAssignAuthority(tankController.netIdentity);
}
}
else
{
// if we do own
if (Input.GetKeyDown(KeyCode.Q))
{
CmdRemoveAuthority(tankController.netIdentity);
}
}
// alternatively we could tell everyone to locally do this and disable NetworkTransform
// it would be more optimal but requires a lil more code
if (tankController.objectOwner == netIdentity)
{
this.transform.position = tankController.seatPosition.position;
}
}
}
void OnTriggerEnter(Collider other)
{
if (!isOwned) return;
//Debug.Log(name + "- OnTriggerEnter - " + other.name);
if (other.name == "TankTrigger")
{
// dont update tank variable if we're in one
if (canControlPlayer)
{
tankController = other.transform.root.GetComponent<TankController>();
}
}
}
void OnTriggerExit(Collider other)
{
if (!isOwned) return;
//Debug.Log(name + "- OnTriggerExit - " + other.name);
if (other.name == "TankTrigger")
{
if (tankController)
{
if (tankController.objectOwner != netIdentity)
{
tankController = null;
}
}
}
}
[Command]
public void CmdAssignAuthority(NetworkIdentity _networkIdentity)
{
// Debug.Log("Mirror Object owner set to: " + this.netIdentity);
tankController = _networkIdentity.GetComponent<TankController>();
// so we dont assign it to same person again
if (tankController.objectOwner != this.netIdentity)
{
// commands are a good place to do additional validation/cheat checks, but these are left out for simplicity here
_networkIdentity.RemoveClientAuthority();
_networkIdentity.AssignClientAuthority(connectionToClient);
tankController.objectOwner = this.netIdentity;
}
}
[Command]
public void CmdRemoveAuthority(NetworkIdentity _networkIdentity)
{
//Debug.Log("Mirror Object owner removed from: " + connectionToClient.identity);
tankController = _networkIdentity.GetComponent<TankController>();
// double check command is sent to remove auth, from owner of object
if (tankController.objectOwner != null && tankController.objectOwner == this.netIdentity)
{
_networkIdentity.RemoveClientAuthority();
tankController.objectOwner = null;
}
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: ecf6aabfdda1548f69448ba0e306af4f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,35 +0,0 @@
using UnityEngine;
namespace Mirror.Examples.TankTheftAuto
{
public class Projectile : NetworkBehaviour
{
public float destroyAfter = 2;
public Rigidbody rigidBody;
public float force = 1000;
public override void OnStartServer()
{
Invoke(nameof(DestroySelf), destroyAfter);
}
// set velocity for server and client. this way we don't have to sync the
// position, because both the server and the client simulate it.
void Start()
{
rigidBody.AddForce(transform.forward * force);
}
// destroy for everyone on the server
[Server]
void DestroySelf()
{
NetworkServer.Destroy(gameObject);
}
// ServerCallback because we don't want a warning
// if OnTriggerEnter is called on the client
[ServerCallback]
void OnTriggerEnter(Collider co) => DestroySelf();
}
}

View File

@ -0,0 +1,151 @@
using System.Collections.Generic;
using UnityEngine;
using Mirror.Examples.Common.Controllers.Tank;
using Mirror.Examples.Common;
using System.Collections;
namespace Mirror.Examples.TankTheftAuto
{
[AddComponentMenu("")]
[DisallowMultipleComponent]
public class TankAuthority : NetworkBehaviour
{
[Header("Components")]
public GameObject triggerUI;
public TankTurret tankTurret;
public GameObject tankTrigger;
[SyncVar(hook = nameof(OnIsControlledChanged))]
public bool isControlled;
void OnIsControlledChanged(bool _, bool newValue)
{
tankTrigger.SetActive(!newValue);
}
protected override void OnValidate()
{
if (Application.isPlaying) return;
base.OnValidate();
Reset();
}
void Reset()
{
if (triggerUI == null)
triggerUI = transform.Find("TriggerUI").gameObject;
if (tankTrigger == null)
tankTrigger = transform.Find("TankTrigger").gameObject;
if (tankTurret == null)
tankTurret = GetComponent<TankTurret>();
triggerUI.SetActive(false);
}
[ClientCallback]
void Update()
{
if (triggerUI.activeSelf && Input.GetKeyDown(KeyCode.C))
CmdTakeControl();
if (isOwned && Input.GetKeyDown(KeyCode.X))
CmdReleaseControl();
}
void OnTriggerEnter(Collider other)
{
if (!isClient || !other.gameObject.CompareTag("Player")) return;
if (other.TryGetComponent(out NetworkIdentity networkIdentity))
if (networkIdentity == NetworkClient.localPlayer)
triggerUI.SetActive(true);
}
void OnTriggerExit(Collider other)
{
if (!isClient || !other.gameObject.CompareTag("Player")) return;
if (other.TryGetComponent(out NetworkIdentity networkIdentity))
if (networkIdentity == NetworkClient.localPlayer)
triggerUI.SetActive(false);
}
[Command(requiresAuthority = false)]
void CmdTakeControl(NetworkConnectionToClient conn = null)
{
// someone else is already controlling this tank
if (connectionToClient != null)
{
Debug.LogWarning("Someone else is already controlling this tank");
return;
}
// cache the regular player object
conn.authenticationData = conn.identity.gameObject;
// set the color to match the player
if (conn.identity.TryGetComponent(out RandomColor randomColor))
tankTurret.playerColor = randomColor.color;
isControlled = true;
// set the player object to be the tank, keep ownership of
// the original player object to avoid ChangeOwner message.
NetworkServer.ReplacePlayerForConnection(conn, gameObject);
StartCoroutine(UnspawnOldPlayer((GameObject)conn.authenticationData));
}
IEnumerator UnspawnOldPlayer(GameObject player)
{
yield return new WaitForSeconds(0.1f);
NetworkServer.UnSpawn(player);
}
[Command]
void CmdReleaseControl()
{
// get the regular player object
if (connectionToClient.authenticationData is GameObject player)
{
// Set pos and rot to match the tank, plus 3m offset to the right
player.transform.SetPositionAndRotation(transform.position + transform.right * 3, transform.rotation);
// set the player object back to the player
isControlled = false;
tankTurret.playerColor = Color.black;
// clear the player object
connectionToClient.authenticationData = null;
NetworkServer.ReplacePlayerForConnection(connectionToClient, player);
}
}
public override void OnStartAuthority()
{
if (triggerUI.TryGetComponent(out TextMesh textMesh))
textMesh.text = "Press 'X' to release control";
}
public override void OnStopAuthority()
{
if (triggerUI.TryGetComponent(out TextMesh textMesh))
textMesh.text = "Press 'C' to take control";
}
public override void OnStartClient()
{
tankTrigger.SetActive(!isControlled);
}
public override void OnStopClient()
{
triggerUI.SetActive(false);
tankTrigger.SetActive(true);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f5af56d9f2233f74ba333eae5c1a17d0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,109 +0,0 @@
using UnityEngine;
using UnityEngine.AI;
namespace Mirror.Examples.TankTheftAuto
{
public class TankController : NetworkBehaviour
{
[Header("Components")]
public NavMeshAgent agent;
public Animator animator;
public Transform turret;
[Header("Movement")]
public float rotationSpeed = 100;
[Header("Firing")]
public KeyCode shootKey = KeyCode.Space;
public GameObject projectilePrefab;
public Transform projectileMount;
void Update()
{
// take input from focused window only
if (!Application.isFocused) return;
// movement for local player
if (isOwned)
{
// rotate
float horizontal = Input.GetAxis("Horizontal");
transform.Rotate(0, horizontal * rotationSpeed * Time.deltaTime, 0);
// move
float vertical = Input.GetAxis("Vertical");
Vector3 forward = transform.TransformDirection(Vector3.forward);
agent.velocity = forward * Mathf.Max(vertical, 0) * agent.speed;
animator.SetBool("Moving", agent.velocity != Vector3.zero);
// shoot
if (Input.GetKeyDown(shootKey))
{
CmdFire();
}
RotateTurret();
}
}
// this is called on the server
[Command]
void CmdFire()
{
GameObject projectile = Instantiate(projectilePrefab, projectileMount.position, projectileMount.rotation);
NetworkServer.Spawn(projectile);
RpcOnFire();
}
// this is called on the tank that fired for all observers
[ClientRpc]
void RpcOnFire()
{
animator.SetTrigger("Shoot");
}
void RotateTurret()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out RaycastHit hit, 100))
{
Debug.DrawLine(ray.origin, hit.point);
Vector3 lookRotation = new Vector3(hit.point.x, turret.transform.position.y, hit.point.z);
turret.transform.LookAt(lookRotation);
}
}
public PlayerController playerController;
public Transform seatPosition;
[SyncVar(hook = nameof(OnOwnerChangedHook))]
public NetworkIdentity objectOwner;
void OnOwnerChangedHook(NetworkIdentity _old, NetworkIdentity _new)
{
//Debug.Log("OnOwnerChangedHook: " + objectOwner);
// not ideal to adjust local players control status (or character model being hidden) via this hook, but it works for now
if (objectOwner)
{
playerController = _new.GetComponent<PlayerController>();
if (playerController) { playerController.canControlPlayer = false; }
}
else if(_old)
{
playerController = _old.GetComponent<PlayerController>();
if (playerController) { playerController.canControlPlayer = true; }
}
}
public override void OnStopServer()
{
// To prevent a bug that can be caused on client host, when scenes do not reset during play,
// tank variables are set as "missing", which Unity does not count as null/empty.
objectOwner = null;
playerController = null;
}
}
}

View File

@ -0,0 +1,30 @@
using Mirror.Examples.Common.Controllers.Tank;
using UnityEngine;
namespace Mirror.Examples.TankTheftAuto
{
[AddComponentMenu("")]
public class TankTheftAutoNetMan : NetworkManager
{
public override void OnServerDisconnect(NetworkConnectionToClient conn)
{
// If the client was driving a tank, destroy the cached player object
if (conn.authenticationData is GameObject player)
NetworkServer.Destroy(player);
if (conn.identity != null)
{
if (conn.identity.TryGetComponent(out TankTurret tankTurret))
tankTurret.playerColor = Color.black;
if (conn.identity.TryGetComponent(out TankAuthority tankAuthority))
{
tankAuthority.isControlled = false;
NetworkServer.RemovePlayerForConnection(conn, RemovePlayerOptions.KeepActive);
}
}
base.OnServerDisconnect(conn);
}
}
}

View File

@ -5,7 +5,7 @@ MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -25,13 +25,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 63476987332307980}
serializedVersion: 2
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.05, y: 0.1, z: 0.05}
m_LocalScale: {x: 0.2, y: 0.2, z: 0.2}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 24373266488650541}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
--- !u!33 &9118274893554935717
MeshFilter:
@ -110,6 +110,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5890560936853567077}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
@ -117,7 +118,6 @@ Transform:
m_Children:
- {fileID: 8035186136109819211}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1713098107664522388
MonoBehaviour:
@ -134,7 +134,7 @@ MonoBehaviour:
sceneId: 0
_assetId: 570694820
serverOnly: 0
visible: 0
visibility: 0
hasSpawned: 0
--- !u!114 &7082621516996595528
MonoBehaviour:
@ -162,11 +162,20 @@ CapsuleCollider:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5890560936853567077}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 1
m_ProvidesContacts: 0
m_Enabled: 1
m_Radius: 0.05
m_Height: 0.2
m_Direction: 1
serializedVersion: 2
m_Radius: 0.1
m_Height: 0.4
m_Direction: 2
m_Center: {x: 0, y: 0, z: 0}
--- !u!54 &4629190479245867726
Rigidbody:
@ -175,10 +184,21 @@ Rigidbody:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5890560936853567077}
serializedVersion: 2
serializedVersion: 4
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_CenterOfMass: {x: 0, y: 0, z: 0}
m_InertiaTensor: {x: 1, y: 1, z: 1}
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_ImplicitCom: 1
m_ImplicitTensor: 1
m_UseGravity: 0
m_IsKinematic: 0
m_Interpolate: 1

View File

@ -11,10 +11,9 @@ GameObject:
- component: {fileID: 4492442352427800}
- component: {fileID: 114118589361100106}
- component: {fileID: 114250499875391520}
- component: {fileID: 3464953498043699706}
- component: {fileID: 114654712548978148}
- component: {fileID: 2240606817507776182}
- component: {fileID: 6900008319038825817}
- component: {fileID: 5194388907919410155}
m_Layer: 0
m_Name: Tank
m_TagString: Untagged
@ -29,14 +28,15 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1916082411674582}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 7831918942946891954}
- {fileID: 4116800716706440423}
- {fileID: 5803173220413450940}
- {fileID: 2155495746218491392}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &114118589361100106
MonoBehaviour:
@ -50,11 +50,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 9b91ecbcc199f4492b9a91e820070131, type: 3}
m_Name:
m_EditorClassIdentifier:
clientStarted: 0
sceneId: 0
_assetId: 3454335836
_assetId: 2638947628
serverOnly: 0
visible: 0
visibility: 0
hasSpawned: 0
--- !u!114 &114250499875391520
MonoBehaviour:
@ -75,6 +74,8 @@ MonoBehaviour:
syncPosition: 1
syncRotation: 1
syncScale: 0
onlySyncOnChange: 1
compressRotation: 1
interpolatePosition: 1
interpolateRotation: 1
interpolateScale: 0
@ -84,9 +85,43 @@ MonoBehaviour:
showGizmos: 0
showOverlay: 0
overlayColor: {r: 0, g: 0, b: 0, a: 0.5}
bufferResetMultiplier: 5
changedDetection: 1
positionSensitivity: 0.01
rotationSensitivity: 0.01
scaleSensitivity: 0.01
--- !u!114 &3464953498043699706
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1916082411674582}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a553cb17010b2403e8523b558bffbc14, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 1
syncMode: 0
syncInterval: 0
target: {fileID: 5803173220413450936}
syncPosition: 0
syncRotation: 1
syncScale: 0
onlySyncOnChange: 1
compressRotation: 1
bufferResetMultiplier: 5
interpolatePosition: 0
interpolateRotation: 1
interpolateScale: 0
coordinateSpace: 0
sendIntervalMultiplier: 1
timelineOffset: 0
showGizmos: 0
showOverlay: 0
overlayColor: {r: 0, g: 0, b: 0, a: 0.5}
bufferResetMultiplier: 3
changedDetection: 1
positionSensitivity: 0.01
rotationSensitivity: 0.01
scaleSensitivity: 0.01
@ -106,34 +141,14 @@ MonoBehaviour:
syncMode: 0
syncInterval: 0.1
agent: {fileID: 6900008319038825817}
animator: {fileID: 2240606817507776182}
healthBar: {fileID: 1985504562751981867}
turret: {fileID: 7831918942946891958}
animator: {fileID: 5803173220405953878}
healthBar: {fileID: 955977906578811009}
turret: {fileID: 5803173220413450936}
rotationSpeed: 80
shootKey: 32
projectilePrefab: {fileID: 5890560936853567077, guid: b7dd46dbf38c643f09e206f9fa4be008,
type: 3}
projectileMount: {fileID: 5718089106632469514}
health: 4
--- !u!95 &2240606817507776182
Animator:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1916082411674582}
m_Enabled: 1
m_Avatar: {fileID: 9000000, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
m_Controller: {fileID: 9100000, guid: a7211483bbd794b6d85ed88576e7d85c, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0
projectilePrefab: {fileID: 5890560936853567077, guid: b7dd46dbf38c643f09e206f9fa4be008, type: 3}
projectileMount: {fileID: 606281948174800110}
health: 5
--- !u!195 &6900008319038825817
NavMeshAgent:
m_ObjectHideFlags: 0
@ -143,8 +158,8 @@ NavMeshAgent:
m_GameObject: {fileID: 1916082411674582}
m_Enabled: 1
m_AgentTypeID: 0
m_Radius: 0.5
m_Speed: 1
m_Radius: 4
m_Speed: 5
m_Acceleration: 1
avoidancePriority: 50
m_AngularSpeed: 120
@ -152,24 +167,11 @@ NavMeshAgent:
m_AutoTraverseOffMeshLink: 1
m_AutoBraking: 1
m_AutoRepath: 1
m_Height: 0.5
m_BaseOffset: 0
m_Height: 3.5
m_BaseOffset: 0.05
m_WalkableMask: 4294967295
m_ObstacleAvoidanceType: 0
--- !u!135 &5194388907919410155
SphereCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1916082411674582}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Center: {x: 0, y: 0.25, z: 0}
--- !u!1 &4730779867780281009
--- !u!1 &6882277736259849937
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -177,40 +179,10 @@ GameObject:
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5718089106632469514}
m_Layer: 0
m_Name: ProjectileMount
m_TagString: Untagged
m_Icon: {fileID: -964228994112308473, guid: 0000000000000000d000000000000000, type: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5718089106632469514
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4730779867780281009}
m_LocalRotation: {x: -0, y: 0.000000119209275, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0.0015906466, z: 0.009359999}
m_LocalScale: {x: 0.01, y: 0.010000003, z: 0.010000002}
m_Children: []
m_Father: {fileID: 7831918942946891958}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &6425560216547760105
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4116800716706440423}
- component: {fileID: 1346539668293290578}
- component: {fileID: 1985504562751981867}
- component: {fileID: 4969305952766559653}
- component: {fileID: 2155495746218491392}
- component: {fileID: 3883687817794100885}
- component: {fileID: 955977906578811009}
- component: {fileID: 6248426133561649027}
m_Layer: 0
m_Name: HealthBar
m_TagString: Untagged
@ -218,35 +190,38 @@ GameObject:
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4116800716706440423
--- !u!4 &2155495746218491392
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6425560216547760105}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0.8, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_GameObject: {fileID: 6882277736259849937}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 0.1, y: 0.1, z: 0.1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4492442352427800}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &1346539668293290578
--- !u!23 &3883687817794100885
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6425560216547760105}
m_GameObject: {fileID: 6882277736259849937}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
@ -271,151 +246,115 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!102 &1985504562751981867
m_AdditionalVertexStreams: {fileID: 0}
--- !u!102 &955977906578811009
TextMesh:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6425560216547760105}
m_Text: ----
m_GameObject: {fileID: 6882277736259849937}
m_Text: -----
m_OffsetZ: 0
m_CharacterSize: 0.02
m_CharacterSize: 1
m_LineSpacing: 1
m_Anchor: 4
m_Alignment: 1
m_TabSize: 4
m_FontSize: 200
m_FontStyle: 1
m_FontSize: 100
m_FontStyle: 0
m_RichText: 1
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_Color:
serializedVersion: 2
rgba: 4285887999
--- !u!114 &4969305952766559653
rgba: 4294967295
--- !u!114 &6248426133561649027
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6425560216547760105}
m_GameObject: {fileID: 6882277736259849937}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: afa2d590c474413d9fc183551385ed85, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &9196118806080746389
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7831918942947312790}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a553cb17010b2403e8523b558bffbc14, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 1
syncMode: 0
syncInterval: 0
target: {fileID: 7831918942946891958}
syncPosition: 0
syncRotation: 1
syncScale: 0
interpolatePosition: 0
interpolateRotation: 1
interpolateScale: 0
coordinateSpace: 0
sendIntervalMultiplier: 3
timelineOffset: 1
showGizmos: 0
showOverlay: 0
overlayColor: {r: 0, g: 0, b: 0, a: 0.5}
onlySyncOnChange: 1
compressRotation: 1
bufferResetMultiplier: 5
positionSensitivity: 0.01
rotationSensitivity: 0.01
scaleSensitivity: 0.01
--- !u!1001 &7831918942947279416
--- !u!1001 &7130959241934869977
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 4492442352427800}
m_Modifications:
- target: {fileID: 100010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
- target: {fileID: 3638700596990255941, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_Name
value: 3D Model
value: BasePrefab
objectReference: {fileID: 0}
- target: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
- target: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 13700000, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 2e67e42170aa64aa9a33424f8045ac89, type: 2}
m_RemovedComponents:
- {fileID: 9500000, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
m_SourcePrefab: {fileID: 100100000, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
--- !u!4 &7831918942946891954 stripped
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
--- !u!4 &606281948174800110 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5,
type: 3}
m_PrefabInstance: {fileID: 7831918942947279416}
m_CorrespondingSourceObject: {fileID: 7683056980803567927, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
m_PrefabInstance: {fileID: 7130959241934869977}
m_PrefabAsset: {fileID: 0}
--- !u!1 &7831918942947312790 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 100014, guid: 38b49695fc0a4418bbc350f2366660c5,
type: 3}
m_PrefabInstance: {fileID: 7831918942947279416}
--- !u!95 &5803173220405953878 stripped
Animator:
m_CorrespondingSourceObject: {fileID: 3638700596980764815, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
m_PrefabInstance: {fileID: 7130959241934869977}
m_PrefabAsset: {fileID: 0}
--- !u!4 &7831918942946891958 stripped
--- !u!4 &5803173220413450936 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 400014, guid: 38b49695fc0a4418bbc350f2366660c5,
type: 3}
m_PrefabInstance: {fileID: 7831918942947279416}
m_CorrespondingSourceObject: {fileID: 3638700596990361441, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
m_PrefabInstance: {fileID: 7130959241934869977}
m_PrefabAsset: {fileID: 0}
--- !u!4 &5803173220413450940 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 3638700596990361445, guid: dad07e68d3659e6439279d0d4110cf4c, type: 3}
m_PrefabInstance: {fileID: 7130959241934869977}
m_PrefabAsset: {fileID: 0}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 343cdf02362f0c247b7f7fd53b99c69a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -38,7 +38,6 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
@ -98,31 +97,31 @@ LightmapSettings:
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_LightingSettings: {fileID: 4890085278179872738, guid: 1cb229a9b0b434acf9cb6b263057a2a0, type: 2}
m_LightingSettings: {fileID: 1064449595}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
serializedVersion: 3
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentRadius: 2
agentHeight: 3.5
agentSlope: 45
agentClimb: 0.4
agentClimb: 2
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
cellSize: 0.6666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
buildHeightMesh: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 23800000, guid: 0bc607fa2e315482ebe98797e844e11f, type: 2}
m_NavMeshData: {fileID: 23800000, guid: c772aa575956c59478e2d55eb019e17a, type: 2}
--- !u!1 &88936773
GameObject:
m_ObjectHideFlags: 0
@ -155,9 +154,17 @@ Camera:
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_Iso: 200
m_ShutterSpeed: 0.005
m_Aperture: 16
m_FocusDistance: 10
m_FocalLength: 50
m_BladeCount: 5
m_Curvature: {x: 2, y: 11}
m_BarrelClipping: 0.25
m_Anamorphism: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
@ -191,14 +198,14 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 88936773}
m_LocalRotation: {x: 0, y: 0.92387956, z: -0.38268343, w: 0}
m_LocalPosition: {x: 0, y: 6.5, z: 8}
serializedVersion: 2
m_LocalRotation: {x: 0.3420201, y: 0, z: 0, w: 0.9396927}
m_LocalPosition: {x: 0, y: 20, z: -30}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 45, y: 180, z: 0}
m_LocalEulerAnglesHint: {x: 40, y: 0, z: 0}
--- !u!114 &88936778
MonoBehaviour:
m_ObjectHideFlags: 0
@ -212,7 +219,9 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
height: 150
offsetY: 40
maxLogCount: 50
showInEditor: 0
hotKey: 293
--- !u!1 &251893064
GameObject:
@ -238,14 +247,14 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 251893064}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 3, y: 0, z: 3}
serializedVersion: 2
m_LocalRotation: {x: 0, y: -0.92387956, z: 0, w: 0.38268343}
m_LocalPosition: {x: 14, y: 0, z: 14}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 0, y: -135, z: 0}
--- !u!114 &251893066
MonoBehaviour:
m_ObjectHideFlags: 0
@ -282,14 +291,14 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 535739935}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 3, y: 0, z: -3}
serializedVersion: 2
m_LocalRotation: {x: 0, y: -0.38268343, z: 0, w: 0.92387956}
m_LocalPosition: {x: 14, y: 0, z: -14}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 0, y: -45, z: 0}
--- !u!114 &535739937
MonoBehaviour:
m_ObjectHideFlags: 0
@ -302,6 +311,70 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 41f84591ce72545258ea98cb7518d8b9, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!850595691 &1064449595
LightingSettings:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Settings.lighting
serializedVersion: 6
m_GIWorkflowMode: 1
m_EnableBakedLightmaps: 0
m_EnableRealtimeLightmaps: 0
m_RealtimeEnvironmentLighting: 1
m_BounceScale: 1
m_AlbedoBoost: 1
m_IndirectOutputScale: 1
m_UsingShadowmask: 1
m_BakeBackend: 0
m_LightmapMaxSize: 1024
m_BakeResolution: 40
m_Padding: 2
m_LightmapCompression: 3
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAO: 0
m_MixedBakeMode: 2
m_LightmapsBakeMode: 1
m_FilterMode: 1
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_RealtimeResolution: 2
m_ForceWhiteAlbedo: 0
m_ForceUpdates: 0
m_FinalGather: 0
m_FinalGatherRayCount: 256
m_FinalGatherFiltering: 1
m_PVRCulling: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVREnvironmentSampleCount: 512
m_PVREnvironmentReferencePointCount: 2048
m_LightProbeSampleCountMultiplier: 4
m_PVRBounces: 2
m_PVRMinBounces: 2
m_PVREnvironmentImportanceSampling: 0
m_PVRFilteringMode: 2
m_PVRDenoiserTypeDirect: 0
m_PVRDenoiserTypeIndirect: 0
m_PVRDenoiserTypeAO: 0
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_PVRTiledBaking: 0
m_NumRaysToShootPerTexel: -1
m_RespectSceneVisibilityWhenBakingGI: 0
--- !u!1 &1107091652
GameObject:
m_ObjectHideFlags: 0
@ -371,9 +444,17 @@ MeshCollider:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1107091652}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 4
serializedVersion: 5
m_Convex: 0
m_CookingOptions: 30
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
@ -392,13 +473,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1107091652}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 4, y: 1, z: 4}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1282001517
GameObject:
@ -427,13 +508,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1282001517}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1282001519
MonoBehaviour:
@ -461,24 +542,30 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 8aab4c8111b7c411b9b92cf3dbc5bd4e, type: 3}
m_Name:
m_EditorClassIdentifier:
dontDestroyOnLoad: 1
dontDestroyOnLoad: 0
runInBackground: 1
autoStartServerBuild: 1
autoConnectClientBuild: 0
headlessStartMode: 1
editorAutoStart: 0
sendRate: 120
autoStartServerBuild: 0
autoConnectClientBuild: 0
offlineScene:
onlineScene:
transport: {fileID: 1282001521}
networkAddress: localhost
maxConnections: 100
disconnectInactiveConnections: 0
disconnectInactiveTimeout: 60
authenticator: {fileID: 0}
playerPrefab: {fileID: 1916082411674582, guid: 6f43bf5488a7443d19ab2a83c6b91f35, type: 3}
autoCreatePlayer: 1
playerSpawnMethod: 1
spawnPrefabs:
- {fileID: 5890560936853567077, guid: b7dd46dbf38c643f09e206f9fa4be008, type: 3}
exceptionsDisconnect: 1
snapshotSettings:
bufferTimeMultiplier: 2
bufferLimit: 32
catchupNegativeThreshold: -1
catchupPositiveThreshold: 1
catchupSpeed: 0.019999999552965164
@ -487,7 +574,9 @@ MonoBehaviour:
dynamicAdjustment: 1
dynamicAdjustmentTolerance: 1
deliveryTimeEmaDuration: 2
timeInterpolationGui: 1
evaluationMethod: 0
evaluationInterval: 3
timeInterpolationGui: 0
--- !u!114 &1282001521
MonoBehaviour:
m_ObjectHideFlags: 0
@ -500,7 +589,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 6b0fecffa3f624585964b0d0eb21b18e, type: 3}
m_Name:
m_EditorClassIdentifier:
Port: 7777
port: 7777
DualMode: 1
NoDelay: 1
Interval: 10
@ -512,8 +601,8 @@ MonoBehaviour:
SendWindowSize: 4096
MaxRetransmit: 40
MaximizeSocketBuffers: 1
ReliableMaxMessageSize: 298449
UnreliableMaxMessageSize: 1199
ReliableMaxMessageSize: 297433
UnreliableMaxMessageSize: 1194
debugLog: 0
statisticsGUI: 0
statisticsLog: 0
@ -557,14 +646,14 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1458789072}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -3, y: 0, z: 3}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0.92387956, z: 0, w: 0.38268343}
m_LocalPosition: {x: -14, y: 0, z: 14}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 0, y: 135, z: 0}
--- !u!114 &1458789074
MonoBehaviour:
m_ObjectHideFlags: 0
@ -601,14 +690,14 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1501912662}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -3, y: 0, z: -3}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0.38268343, z: 0, w: 0.92387956}
m_LocalPosition: {x: -14, y: 0, z: -14}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 0, y: 45, z: 0}
--- !u!114 &1501912664
MonoBehaviour:
m_ObjectHideFlags: 0
@ -707,11 +796,23 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2054208274}
serializedVersion: 2
m_LocalRotation: {x: 0.10938167, y: 0.8754261, z: -0.40821788, w: 0.23456976}
m_LocalPosition: {x: 0, y: 10, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 50, y: 150, z: 0}
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0
m_Roots:
- {fileID: 2054208276}
- {fileID: 1107091656}
- {fileID: 88936777}
- {fileID: 1282001518}
- {fileID: 251893065}
- {fileID: 535739936}
- {fileID: 1458789073}
- {fileID: 1501912663}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c772aa575956c59478e2d55eb019e17a
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 23800000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,94 @@
using System.Collections.Generic;
using UnityEngine;
using Mirror;
[RequireComponent(typeof(Rigidbody))]
[RequireComponent(typeof(NetworkIdentity))]
[RequireComponent(typeof(NetworkTransformReliable))]
[DisallowMultipleComponent]
public class Box : NetworkBehaviour
{
[Header("Components")]
public Rigidbody rigidBody;
#region Unity Callbacks
/// <summary>
/// Add your validation code here after the base.OnValidate(); call.
/// </summary>
protected override void OnValidate()
{
if (Application.isPlaying) return;
base.OnValidate();
Reset();
}
void Reset()
{
rigidBody = GetComponent<Rigidbody>();
rigidBody.isKinematic = true;
}
#endregion
#region Start & Stop Callbacks
/// <summary>
/// This is invoked for NetworkBehaviour objects when they become active on the server.
/// <para>This could be triggered by NetworkServer.Listen() for objects in the scene, or by NetworkServer.Spawn() for objects that are dynamically created.</para>
/// <para>This will be called for objects on a "host" as well as for object on a dedicated server.</para>
/// </summary>
public override void OnStartServer()
{
rigidBody.isKinematic = false;
}
/// <summary>
/// Invoked on the server when the object is unspawned
/// <para>Useful for saving object data in persistent storage</para>
/// </summary>
public override void OnStopServer()
{
rigidBody.isKinematic = true;
}
/// <summary>
/// Called on every NetworkBehaviour when it is activated on a client.
/// <para>Objects on the host have this function called, as there is a local client on the host. The values of SyncVars on object are guaranteed to be initialized correctly with the latest state from the server when this function is called on the client.</para>
/// </summary>
public override void OnStartClient() { }
/// <summary>
/// This is invoked on clients when the server has caused this object to be destroyed.
/// <para>This can be used as a hook to invoke effects or do client specific cleanup.</para>
/// </summary>
public override void OnStopClient() { }
/// <summary>
/// Called when the local player object has been set up.
/// <para>This happens after OnStartClient(), as it is triggered by an ownership message from the server. This is an appropriate place to activate components or functionality that should only be active for the local player, such as cameras and input.</para>
/// </summary>
public override void OnStartLocalPlayer() { }
/// <summary>
/// Called when the local player object is being stopped.
/// <para>This happens before OnStopClient(), as it may be triggered by an ownership message from the server, or because the player object is being destroyed. This is an appropriate place to deactivate components or functionality that should only be active for the local player, such as cameras and input.</para>
/// </summary>
public override void OnStopLocalPlayer() {}
/// <summary>
/// This is invoked on behaviours that have authority, based on context and <see cref="NetworkIdentity.hasAuthority">NetworkIdentity.hasAuthority</see>.
/// <para>This is called after <see cref="OnStartServer">OnStartServer</see> and before <see cref="OnStartClient">OnStartClient.</see></para>
/// <para>When <see cref="NetworkIdentity.AssignClientAuthority">AssignClientAuthority</see> is called on the server, this will be called on the client that owns the object. When an object is spawned with <see cref="NetworkServer.Spawn">NetworkServer.Spawn</see> with a NetworkConnectionToClient parameter included, this will be called on the client that owns the object.</para>
/// </summary>
public override void OnStartAuthority() { }
/// <summary>
/// This is invoked on behaviours when authority is removed.
/// <para>When NetworkIdentity.RemoveClientAuthority is called on the server, this will be called on the client that owns the object.</para>
/// </summary>
public override void OnStopAuthority() { }
#endregion
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 479a5196564ede84791870b414a13645
guid: bf9fc8899cb57ff4faff8849692b109f
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -4,9 +4,9 @@ namespace Mirror.Examples.Tanks
{
public class Projectile : NetworkBehaviour
{
public float destroyAfter = 2;
public float destroyAfter = 2f;
public Rigidbody rigidBody;
public float force = 1000;
public float force = 1000f;
public override void OnStartServer()
{
@ -30,6 +30,17 @@ void DestroySelf()
// ServerCallback because we don't want a warning
// if OnTriggerEnter is called on the client
[ServerCallback]
void OnTriggerEnter(Collider co) => DestroySelf();
void OnTriggerEnter(Collider other)
{
Debug.Log("Hit: " + other.name);
if (other.transform.parent.TryGetComponent(out Tank tank))
{
--tank.health;
if (tank.health == 0)
NetworkServer.RemovePlayerForConnection(tank.netIdentity.connectionToClient, RemovePlayerOptions.Destroy);
DestroySelf();
}
}
}
}

View File

@ -20,7 +20,7 @@ public class Tank : NetworkBehaviour
public Transform projectileMount;
[Header("Stats")]
[SyncVar] public int health = 4;
[SyncVar] public int health = 5;
void Update()
{
@ -70,16 +70,16 @@ void RpcOnFire()
animator.SetTrigger("Shoot");
}
[ServerCallback]
void OnTriggerEnter(Collider other)
{
if (other.GetComponent<Projectile>() != null)
{
--health;
if (health == 0)
NetworkServer.Destroy(gameObject);
}
}
//[ServerCallback]
//void OnTriggerEnter(Collider other)
//{
// if (other.GetComponent<Projectile>() != null)
// {
// --health;
// if (health == 0)
// NetworkServer.Destroy(gameObject);
// }
//}
void RotateTurret()
{

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5a55c087b5addd340a1b3ac030346041
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,182 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Mirror.Examples.Common.Controllers
{
[AddComponentMenu("")]
[DisallowMultipleComponent]
public class ContollerUIBase : MonoBehaviour
{
// Returns a string representation of a KeyCode that is more suitable
// for display in the UI than KeyCode.ToString() for "named" keys.
internal string GetKeyText(KeyCode key)
{
switch (key)
{
case KeyCode.None:
return "";
case KeyCode.Escape:
return "Esc";
case KeyCode.BackQuote:
return "`";
case KeyCode.Tilde:
return "~";
// number keys
case KeyCode.Alpha1:
return "1";
case KeyCode.Alpha2:
return "2";
case KeyCode.Alpha3:
return "3";
case KeyCode.Alpha4:
return "4";
case KeyCode.Alpha5:
return "5";
case KeyCode.Alpha6:
return "6";
case KeyCode.Alpha7:
return "7";
case KeyCode.Alpha8:
return "8";
case KeyCode.Alpha9:
return "9";
case KeyCode.Alpha0:
return "0";
// punctuation keys
case KeyCode.Exclaim:
return "!";
case KeyCode.At:
return "@";
case KeyCode.Hash:
return "#";
case KeyCode.Dollar:
return "$";
case KeyCode.Percent:
return "%";
case KeyCode.Caret:
return "^";
case KeyCode.Ampersand:
return "&";
case KeyCode.Asterisk:
return "*";
case KeyCode.LeftParen:
return "(";
case KeyCode.RightParen:
return ")";
case KeyCode.Minus:
return "-";
case KeyCode.Underscore:
return "_";
case KeyCode.Plus:
return "+";
case KeyCode.Equals:
return "=";
case KeyCode.Backspace:
return "Back";
case KeyCode.LeftBracket:
return "[";
case KeyCode.LeftCurlyBracket:
return "{";
case KeyCode.RightBracket:
return "]";
case KeyCode.RightCurlyBracket:
return "}";
case KeyCode.Pipe:
return "|";
case KeyCode.Backslash:
return "\\";
case KeyCode.Semicolon:
return ";";
case KeyCode.Colon:
return ":";
case KeyCode.Quote:
return "'";
case KeyCode.DoubleQuote:
return "\"";
case KeyCode.Return:
return "\u23CE";
case KeyCode.Comma:
return ",";
case KeyCode.Less:
return "<";
case KeyCode.Period:
return ".";
case KeyCode.Greater:
return ">";
case KeyCode.Slash:
return "/";
case KeyCode.Question:
return "?";
// arrow keys
case KeyCode.UpArrow:
return "\u25B2";
case KeyCode.LeftArrow:
return "\u25C4";
case KeyCode.DownArrow:
return "\u25BC";
case KeyCode.RightArrow:
return "\u25BA";
// special keys
case KeyCode.PageUp:
return "Page\nUp";
case KeyCode.PageDown:
return "Page\nDown";
case KeyCode.Insert:
return "Ins";
case KeyCode.Delete:
return "Del";
// num pad keys
case KeyCode.Keypad1:
return "Pad\n1";
case KeyCode.Keypad2:
return "Pad\n2";
case KeyCode.Keypad3:
return "Pad\n3";
case KeyCode.Keypad4:
return "Pad\n4";
case KeyCode.Keypad5:
return "Pad\n5";
case KeyCode.Keypad6:
return "Pad\n6";
case KeyCode.Keypad7:
return "Pad\n7";
case KeyCode.Keypad8:
return "Pad\n8";
case KeyCode.Keypad9:
return "Pad\n9";
case KeyCode.Keypad0:
return "Pad\n0";
case KeyCode.KeypadDivide:
return "Pad\n/";
case KeyCode.KeypadMultiply:
return "Pad\n*";
case KeyCode.KeypadMinus:
return "Pad\n-";
case KeyCode.KeypadPlus:
return "Pad\n+";
case KeyCode.KeypadEquals:
return "Pad\n=";
case KeyCode.KeypadPeriod:
return "Pad\n.";
case KeyCode.KeypadEnter:
return "Pad\n\u23CE";
default:
return key.ToString();
}
}
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 05e10150710dde14b83d3c8f5aa853c2
guid: 6b8c728d262078147bf398cd80ff4b7d
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5f7c2b0cb9aa8454a837825241e3bc0e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,504 @@
using System;
using UnityEngine;
using UnityEngine.Serialization;
namespace Mirror.Examples.Common.Controllers.Flyer
{
[AddComponentMenu("")]
[RequireComponent(typeof(PlayerCamera))]
[RequireComponent(typeof(Rigidbody))]
[RequireComponent(typeof(CapsuleCollider))]
[RequireComponent(typeof(CharacterController))]
[RequireComponent(typeof(NetworkIdentity))]
[RequireComponent(typeof(NetworkTransformReliable))]
[DisallowMultipleComponent]
public class FlyerController : NetworkBehaviour
{
const float BASE_DPI = 96f;
[Serializable]
public struct OptionsKeys
{
public KeyCode MouseSteer;
public KeyCode AutoRun;
public KeyCode ToggleUI;
}
public enum GroundState : byte { Jumping, Falling, Grounded }
[Serializable]
public struct MoveKeys
{
public KeyCode Forward;
public KeyCode Back;
public KeyCode StrafeLeft;
public KeyCode StrafeRight;
public KeyCode TurnLeft;
public KeyCode TurnRight;
}
[Serializable]
public struct FlightKeys
{
public KeyCode PitchDown;
public KeyCode PitchUp;
public KeyCode RollLeft;
public KeyCode RollRight;
public KeyCode AutoLevel;
}
[Flags]
public enum ControlOptions : byte
{
None,
MouseSteer = 1 << 0,
AutoRun = 1 << 1,
AutoLevel = 1 << 2,
ShowUI = 1 << 3
}
[Header("Avatar Components")]
public CapsuleCollider capsuleCollider;
public CharacterController characterController;
[Header("User Interface")]
public GameObject ControllerUIPrefab;
[Header("Configuration")]
[SerializeField]
public MoveKeys moveKeys = new MoveKeys
{
Forward = KeyCode.W,
Back = KeyCode.S,
StrafeLeft = KeyCode.A,
StrafeRight = KeyCode.D,
TurnLeft = KeyCode.Q,
TurnRight = KeyCode.E
};
[SerializeField]
public FlightKeys flightKeys = new FlightKeys
{
PitchDown = KeyCode.UpArrow,
PitchUp = KeyCode.DownArrow,
RollLeft = KeyCode.LeftArrow,
RollRight = KeyCode.RightArrow,
AutoLevel = KeyCode.L
};
[SerializeField]
public OptionsKeys optionsKeys = new OptionsKeys
{
MouseSteer = KeyCode.M,
AutoRun = KeyCode.R,
ToggleUI = KeyCode.U
};
[Space(5)]
public ControlOptions controlOptions = ControlOptions.AutoLevel | ControlOptions.ShowUI;
[Header("Movement")]
[Range(0, 20)]
[FormerlySerializedAs("moveSpeedMultiplier")]
[Tooltip("Speed in meters per second")]
public float maxMoveSpeed = 8f;
// Replacement for Sensitvity from Input Settings.
[Range(0, 10f)]
[Tooltip("Sensitivity factors into accelleration")]
public float inputSensitivity = 2f;
// Replacement for Gravity from Input Settings.
[Range(0, 10f)]
[Tooltip("Gravity factors into decelleration")]
public float inputGravity = 2f;
[Header("Turning")]
[Range(0, 300f)]
[Tooltip("Max Rotation in degrees per second")]
public float maxTurnSpeed = 100f;
[Range(0, 10f)]
[FormerlySerializedAs("turnDelta")]
[Tooltip("Rotation acceleration in degrees per second squared")]
public float turnAcceleration = 3f;
[Header("Pitch")]
[Range(0, 180f)]
[Tooltip("Max Pitch in degrees per second")]
public float maxPitchSpeed = 30f;
[Range(0, 180f)]
[Tooltip("Max Pitch in degrees")]
public float maxPitchUpAngle = 20f;
[Range(0, 180f)]
[Tooltip("Max Pitch in degrees")]
public float maxPitchDownAngle = 45f;
[Range(0, 10f)]
[Tooltip("Pitch acceleration in degrees per second squared")]
public float pitchAcceleration = 3f;
[Header("Roll")]
[Range(0, 180f)]
[Tooltip("Max Roll in degrees per second")]
public float maxRollSpeed = 30f;
[Range(0, 180f)]
[Tooltip("Max Roll in degrees")]
public float maxRollAngle = 45f;
[Range(0, 10f)]
[Tooltip("Roll acceleration in degrees per second squared")]
public float rollAcceleration = 3f;
[Header("Diagnostics")]
[ReadOnly, SerializeField]
GroundState groundState = GroundState.Grounded;
[ReadOnly, SerializeField, Range(-1f, 1f)]
float horizontal;
[ReadOnly, SerializeField, Range(-1f, 1f)]
float vertical;
[ReadOnly, SerializeField, Range(-1f, 1f)]
float mouseInputX;
[ReadOnly, SerializeField, Range(0, 30f)]
float mouseSensitivity;
[ReadOnly, SerializeField, Range(-300f, 300f)]
float turnSpeed;
[ReadOnly, SerializeField, Range(-180f, 180f)]
float pitchAngle;
[ReadOnly, SerializeField, Range(-180f, 180f)]
float pitchSpeed;
[ReadOnly, SerializeField, Range(-180f, 180f)]
float rollAngle;
[ReadOnly, SerializeField, Range(-180f, 180f)]
float rollSpeed;
[ReadOnly, SerializeField, Range(-1.5f, 1.5f)]
float animVelocity;
[ReadOnly, SerializeField, Range(-1.5f, 1.5f)]
float animRotation;
[ReadOnly, SerializeField]
Vector3 direction;
[ReadOnly, SerializeField]
Vector3Int velocity;
[ReadOnly, SerializeField]
GameObject controllerUI;
#region Network Setup
protected override void OnValidate()
{
// Skip if Editor is in Play mode
if (Application.isPlaying) return;
base.OnValidate();
Reset();
}
void Reset()
{
if (capsuleCollider == null)
capsuleCollider = GetComponent<CapsuleCollider>();
// Enable by default...it will be disabled when characterController is enabled
capsuleCollider.enabled = true;
if (characterController == null)
characterController = GetComponent<CharacterController>();
// Override CharacterController default values
characterController.enabled = false;
characterController.skinWidth = 0.02f;
characterController.minMoveDistance = 0f;
GetComponent<Rigidbody>().isKinematic = true;
#if UNITY_EDITOR
// For convenience in the examples, we use the GUID of the FlyerControllerUI
// to find the correct prefab in the Mirror/Examples/_Common/Controllers folder.
// This avoids conflicts with user-created prefabs that may have the same name
// and avoids polluting the user's project with Resources.
// This is not recommended for production code...use Resources.Load or AssetBundles instead.
if (ControllerUIPrefab == null)
{
string path = UnityEditor.AssetDatabase.GUIDToAssetPath("493615025d304c144bacfb91f6aac90e");
ControllerUIPrefab = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(path);
}
#endif
this.enabled = false;
}
public override void OnStartAuthority()
{
// Calculate DPI-aware sensitivity
float dpiScale = (Screen.dpi > 0) ? (Screen.dpi / BASE_DPI) : 1f;
mouseSensitivity = turnAcceleration * dpiScale;
//Debug.Log($"Screen DPI: {Screen.dpi}, DPI Scale: {dpiScale}, Adjusted Turn Acceleration: {turnAccelerationDPI}");
SetCursor(controlOptions.HasFlag(ControlOptions.MouseSteer));
// capsuleCollider and characterController are mutually exclusive
// Having both enabled would double fire triggers and other collisions
capsuleCollider.enabled = false;
characterController.enabled = true;
this.enabled = true;
}
public override void OnStopAuthority()
{
this.enabled = false;
// capsuleCollider and characterController are mutually exclusive
// Having both enabled would double fire triggers and other collisions
capsuleCollider.enabled = true;
characterController.enabled = false;
SetCursor(false);
}
public override void OnStartLocalPlayer()
{
if (ControllerUIPrefab != null)
controllerUI = Instantiate(ControllerUIPrefab);
if (controllerUI != null)
{
if (controllerUI.TryGetComponent(out FlyerControllerUI canvasControlPanel))
canvasControlPanel.Refresh(moveKeys, flightKeys, optionsKeys);
controllerUI.SetActive(controlOptions.HasFlag(ControlOptions.ShowUI));
}
}
public override void OnStopLocalPlayer()
{
if (controllerUI != null)
Destroy(controllerUI);
controllerUI = null;
}
#endregion
void Update()
{
if (!characterController.enabled)
return;
float deltaTime = Time.deltaTime;
HandleOptions();
if (controlOptions.HasFlag(ControlOptions.MouseSteer))
HandleMouseSteer(deltaTime);
else
HandleTurning(deltaTime);
HandlePitch(deltaTime);
HandleRoll(deltaTime);
HandleMove(deltaTime);
ApplyMove(deltaTime);
// Reset ground state
if (characterController.isGrounded)
groundState = GroundState.Grounded;
else if (groundState != GroundState.Jumping)
groundState = GroundState.Falling;
// Diagnostic velocity...FloorToInt for display purposes
velocity = Vector3Int.FloorToInt(characterController.velocity);
}
void SetCursor(bool locked)
{
Cursor.lockState = locked ? CursorLockMode.Locked : CursorLockMode.None;
Cursor.visible = !locked;
}
void HandleOptions()
{
if (optionsKeys.MouseSteer != KeyCode.None && Input.GetKeyUp(optionsKeys.MouseSteer))
{
controlOptions ^= ControlOptions.MouseSteer;
SetCursor(controlOptions.HasFlag(ControlOptions.MouseSteer));
}
if (optionsKeys.AutoRun != KeyCode.None && Input.GetKeyUp(optionsKeys.AutoRun))
controlOptions ^= ControlOptions.AutoRun;
if (optionsKeys.ToggleUI != KeyCode.None && Input.GetKeyUp(optionsKeys.ToggleUI))
{
controlOptions ^= ControlOptions.ShowUI;
if (controllerUI != null)
controllerUI.SetActive(controlOptions.HasFlag(ControlOptions.ShowUI));
}
if (flightKeys.AutoLevel != KeyCode.None && Input.GetKeyUp(flightKeys.AutoLevel))
controlOptions ^= ControlOptions.AutoLevel;
}
// Turning works while airborne...feature?
void HandleTurning(float deltaTime)
{
float targetTurnSpeed = 0f;
// Q and E cancel each other out, reducing targetTurnSpeed to zero.
if (moveKeys.TurnLeft != KeyCode.None && Input.GetKey(moveKeys.TurnLeft))
targetTurnSpeed -= maxTurnSpeed;
if (moveKeys.TurnRight != KeyCode.None && Input.GetKey(moveKeys.TurnRight))
targetTurnSpeed += maxTurnSpeed;
turnSpeed = Mathf.MoveTowards(turnSpeed, targetTurnSpeed, turnAcceleration * maxTurnSpeed * deltaTime);
transform.Rotate(0f, turnSpeed * deltaTime, 0f);
}
void HandleMouseSteer(float deltaTime)
{
// Accumulate mouse input over time
mouseInputX += Input.GetAxisRaw("Mouse X") * mouseSensitivity;
// Clamp the accumulator to simulate key press behavior
mouseInputX = Mathf.Clamp(mouseInputX, -1f, 1f);
// Calculate target turn speed
float targetTurnSpeed = mouseInputX * maxTurnSpeed;
// Use the same acceleration logic as HandleTurning
turnSpeed = Mathf.MoveTowards(turnSpeed, targetTurnSpeed, mouseSensitivity * maxTurnSpeed * deltaTime);
// Apply rotation
transform.Rotate(0f, turnSpeed * deltaTime, 0f);
// Decay the accumulator over time
//float decayRate = 5f; // Adjust as needed
//mouseInputX = Mathf.MoveTowards(mouseInputX, 0f, decayRate * deltaTime);
mouseInputX = Mathf.MoveTowards(mouseInputX, 0f, mouseSensitivity * deltaTime);
}
void HandlePitch(float deltaTime)
{
float targetPitchSpeed = 0f;
bool inputDetected = false;
// Up and Down arrows for pitch
if (flightKeys.PitchUp != KeyCode.None && Input.GetKey(flightKeys.PitchUp))
{
targetPitchSpeed -= maxPitchSpeed;
inputDetected = true;
}
if (flightKeys.PitchDown != KeyCode.None && Input.GetKey(flightKeys.PitchDown))
{
targetPitchSpeed += maxPitchSpeed;
inputDetected = true;
}
pitchSpeed = Mathf.MoveTowards(pitchSpeed, targetPitchSpeed, pitchAcceleration * maxPitchSpeed * deltaTime);
// Apply pitch rotation
pitchAngle += pitchSpeed * deltaTime;
pitchAngle = Mathf.Clamp(pitchAngle, -maxPitchUpAngle, maxPitchDownAngle);
// Return to zero when no input
if (!inputDetected && controlOptions.HasFlag(ControlOptions.AutoLevel))
pitchAngle = Mathf.MoveTowards(pitchAngle, 0f, maxPitchSpeed * deltaTime);
ApplyRotation();
}
void HandleRoll(float deltaTime)
{
float targetRollSpeed = 0f;
bool inputDetected = false;
// Left and Right arrows for roll
if (flightKeys.RollRight != KeyCode.None && Input.GetKey(flightKeys.RollRight))
{
targetRollSpeed -= maxRollSpeed;
inputDetected = true;
}
if (flightKeys.RollLeft != KeyCode.None && Input.GetKey(flightKeys.RollLeft))
{
targetRollSpeed += maxRollSpeed;
inputDetected = true;
}
rollSpeed = Mathf.MoveTowards(rollSpeed, targetRollSpeed, rollAcceleration * maxRollSpeed * deltaTime);
// Apply roll rotation
rollAngle += rollSpeed * deltaTime;
rollAngle = Mathf.Clamp(rollAngle, -maxRollAngle, maxRollAngle);
// Return to zero when no input
if (!inputDetected && controlOptions.HasFlag(ControlOptions.AutoLevel))
rollAngle = Mathf.MoveTowards(rollAngle, 0f, maxRollSpeed * deltaTime);
ApplyRotation();
}
void ApplyRotation()
{
// Get the current yaw (Y-axis rotation)
float currentYaw = transform.localRotation.eulerAngles.y;
// Apply all rotations
transform.localRotation = Quaternion.Euler(pitchAngle, currentYaw, rollAngle);
}
void HandleMove(float deltaTime)
{
// Initialize target movement variables
float targetMoveX = 0f;
float targetMoveZ = 0f;
// Check for WASD key presses and adjust target movement variables accordingly
if (moveKeys.Forward != KeyCode.None && Input.GetKey(moveKeys.Forward)) targetMoveZ = 1f;
if (moveKeys.Back != KeyCode.None && Input.GetKey(moveKeys.Back)) targetMoveZ = -1f;
if (moveKeys.StrafeLeft != KeyCode.None && Input.GetKey(moveKeys.StrafeLeft)) targetMoveX = -1f;
if (moveKeys.StrafeRight != KeyCode.None && Input.GetKey(moveKeys.StrafeRight)) targetMoveX = 1f;
if (targetMoveX == 0f)
{
if (!controlOptions.HasFlag(ControlOptions.AutoRun))
horizontal = Mathf.MoveTowards(horizontal, targetMoveX, inputGravity * deltaTime);
}
else
horizontal = Mathf.MoveTowards(horizontal, targetMoveX, inputSensitivity * deltaTime);
if (targetMoveZ == 0f)
{
if (!controlOptions.HasFlag(ControlOptions.AutoRun))
vertical = Mathf.MoveTowards(vertical, targetMoveZ, inputGravity * deltaTime);
}
else
vertical = Mathf.MoveTowards(vertical, targetMoveZ, inputSensitivity * deltaTime);
}
void ApplyMove(float deltaTime)
{
// Create initial direction vector without jumpSpeed (y-axis).
direction = new Vector3(horizontal, 0f, vertical);
// Clamp so diagonal strafing isn't a speed advantage.
direction = Vector3.ClampMagnitude(direction, 1f);
// Transforms direction from local space to world space.
direction = transform.TransformDirection(direction);
// Multiply for desired ground speed.
direction *= maxMoveSpeed;
//// Add jumpSpeed to direction as last step.
//direction.y = jumpSpeed;
// Finally move the character.
characterController.Move(direction * deltaTime);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d7616003f8b749c43943908c2daa4e5d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,67 @@
using System;
using UnityEngine;
using UnityEngine.UI;
namespace Mirror.Examples.Common.Controllers.Flyer
{
[AddComponentMenu("")]
[DisallowMultipleComponent]
public class FlyerControllerUI : ContollerUIBase
{
[Serializable]
public struct MoveTexts
{
public Text keyTextTurnLeft;
public Text keyTextForward;
public Text keyTextTurnRight;
public Text keyTextStrafeLeft;
public Text keyTextBack;
public Text keyTextStrafeRight;
}
[Serializable]
public struct FlightTexts
{
public Text keyTextPitchDown;
public Text keyTextPitchUp;
public Text keyTextRollLeft;
public Text keyTextRollRight;
public Text keyTextAutoLevel;
}
[Serializable]
public struct OptionsTexts
{
public Text keyTextMouseSteer;
public Text keyTextAutoRun;
public Text keyTextToggleUI;
}
[SerializeField] MoveTexts moveTexts;
[SerializeField] FlightTexts flightTexts;
[SerializeField] OptionsTexts optionsTexts;
public void Refresh(FlyerController.MoveKeys moveKeys, FlyerController.FlightKeys flightKeys, FlyerController.OptionsKeys optionsKeys)
{
// Movement Keys
moveTexts.keyTextTurnLeft.text = GetKeyText(moveKeys.TurnLeft);
moveTexts.keyTextForward.text = GetKeyText(moveKeys.Forward);
moveTexts.keyTextTurnRight.text = GetKeyText(moveKeys.TurnRight);
moveTexts.keyTextStrafeLeft.text = GetKeyText(moveKeys.StrafeLeft);
moveTexts.keyTextBack.text = GetKeyText(moveKeys.Back);
moveTexts.keyTextStrafeRight.text = GetKeyText(moveKeys.StrafeRight);
// Flight Keys
flightTexts.keyTextPitchDown.text = GetKeyText(flightKeys.PitchDown);
flightTexts.keyTextPitchUp.text = GetKeyText(flightKeys.PitchUp);
flightTexts.keyTextRollLeft.text = GetKeyText(flightKeys.RollLeft);
flightTexts.keyTextRollRight.text = GetKeyText(flightKeys.RollRight);
flightTexts.keyTextAutoLevel.text = GetKeyText(flightKeys.AutoLevel);
// Options Keys
optionsTexts.keyTextMouseSteer.text = GetKeyText(optionsKeys.MouseSteer);
optionsTexts.keyTextAutoRun.text = GetKeyText(optionsKeys.AutoRun);
optionsTexts.keyTextToggleUI.text = GetKeyText(optionsKeys.ToggleUI);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 46a320327396d584faba2bffc73278ec
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 493615025d304c144bacfb91f6aac90e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: abc9f9284fe9a1a4ab4deac2e4b504ec
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,411 @@
using System;
using UnityEngine;
using UnityEngine.Serialization;
namespace Mirror.Examples.Common.Controllers.Player
{
[AddComponentMenu("")]
[RequireComponent(typeof(PlayerCamera))]
[RequireComponent(typeof(Rigidbody))]
[RequireComponent(typeof(CapsuleCollider))]
[RequireComponent(typeof(CharacterController))]
[RequireComponent(typeof(NetworkIdentity))]
[RequireComponent(typeof(NetworkTransformReliable))]
[DisallowMultipleComponent]
public class PlayerController : NetworkBehaviour
{
const float BASE_DPI = 96f;
public enum GroundState : byte { Jumping, Falling, Grounded }
[Serializable]
public struct MoveKeys
{
public KeyCode Forward;
public KeyCode Back;
public KeyCode StrafeLeft;
public KeyCode StrafeRight;
public KeyCode TurnLeft;
public KeyCode TurnRight;
public KeyCode Jump;
}
[Serializable]
public struct OptionsKeys
{
public KeyCode MouseSteer;
public KeyCode AutoRun;
public KeyCode ToggleUI;
}
[Flags]
public enum ControlOptions : byte
{
None,
MouseSteer = 1 << 0,
AutoRun = 1 << 1,
ShowUI = 1 << 2
}
[Header("Avatar Components")]
public CharacterController characterController;
[Header("User Interface")]
public GameObject ControllerUIPrefab;
[Header("Configuration")]
[SerializeField]
public MoveKeys moveKeys = new MoveKeys
{
Forward = KeyCode.W,
Back = KeyCode.S,
StrafeLeft = KeyCode.A,
StrafeRight = KeyCode.D,
TurnLeft = KeyCode.Q,
TurnRight = KeyCode.E,
Jump = KeyCode.Space,
};
[SerializeField]
public OptionsKeys optionsKeys = new OptionsKeys
{
MouseSteer = KeyCode.M,
AutoRun = KeyCode.R,
ToggleUI = KeyCode.U
};
[Space(5)]
public ControlOptions controlOptions = ControlOptions.ShowUI;
[Header("Movement")]
[Range(0, 20)]
[FormerlySerializedAs("moveSpeedMultiplier")]
[Tooltip("Speed in meters per second")]
public float maxMoveSpeed = 8f;
// Replacement for Sensitvity from Input Settings.
[Range(0, 10f)]
[Tooltip("Sensitivity factors into accelleration")]
public float inputSensitivity = 2f;
// Replacement for Gravity from Input Settings.
[Range(0, 10f)]
[Tooltip("Gravity factors into decelleration")]
public float inputGravity = 2f;
[Header("Jumping")]
[Range(0, 10f)]
[Tooltip("Initial jump speed in meters per second")]
public float initialJumpSpeed = 2.5f;
[Range(0, 10f)]
[Tooltip("Maximum jump speed in meters per second")]
public float maxJumpSpeed = 3.5f;
[Range(0, 10f)]
[FormerlySerializedAs("jumpDelta")]
[Tooltip("Jump acceleration in meters per second squared")]
public float jumpAcceleration = 4f;
[Header("Turning")]
[Range(0, 300f)]
[Tooltip("Max Rotation in degrees per second")]
public float maxTurnSpeed = 100f;
[Range(0, 10f)]
[FormerlySerializedAs("turnDelta")]
[Tooltip("Rotation acceleration in degrees per second squared")]
public float turnAcceleration = 3f;
//[Range(0, 10f)]
//[Tooltip("Sensitivity factors into accelleration")]
//public float mouseSensitivity = 2f;
[Header("Diagnostics")]
[ReadOnly, SerializeField]
GroundState groundState = GroundState.Grounded;
[ReadOnly, SerializeField, Range(-1f, 1f)]
float horizontal;
[ReadOnly, SerializeField, Range(-1f, 1f)]
float vertical;
[ReadOnly, SerializeField, Range(-1f, 1f)]
float mouseInputX;
[ReadOnly, SerializeField, Range(0, 30f)]
float mouseSensitivity;
[ReadOnly, SerializeField, Range(-300f, 300f)]
float turnSpeed;
[ReadOnly, SerializeField, Range(-10f, 10f)]
float jumpSpeed;
[ReadOnly, SerializeField, Range(-1.5f, 1.5f)]
float animVelocity;
[ReadOnly, SerializeField, Range(-1.5f, 1.5f)]
float animRotation;
[ReadOnly, SerializeField]
Vector3 direction;
[ReadOnly, SerializeField]
Vector3Int velocity;
[ReadOnly, SerializeField]
GameObject controllerUI;
#region Network Setup
protected override void OnValidate()
{
// Skip if Editor is in Play mode
if (Application.isPlaying) return;
base.OnValidate();
Reset();
}
void Reset()
{
if (characterController == null)
characterController = GetComponent<CharacterController>();
// Override CharacterController default values
characterController.enabled = false;
characterController.skinWidth = 0.02f;
characterController.minMoveDistance = 0f;
GetComponent<Rigidbody>().isKinematic = true;
#if UNITY_EDITOR
// For convenience in the examples, we use the GUID of the PlayerControllerUI
// to find the correct prefab in the Mirror/Examples/_Common/Controllers folder.
// This avoids conflicts with user-created prefabs that may have the same name
// and avoids polluting the user's project with Resources.
// This is not recommended for production code...use Resources.Load or AssetBundles instead.
if (ControllerUIPrefab == null)
{
string path = UnityEditor.AssetDatabase.GUIDToAssetPath("7beee247444994f0281dadde274cc4af");
ControllerUIPrefab = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(path);
}
#endif
this.enabled = false;
}
public override void OnStartAuthority()
{
// Calculate DPI-aware sensitivity
float dpiScale = (Screen.dpi > 0) ? (Screen.dpi / BASE_DPI) : 1f;
mouseSensitivity = turnAcceleration * dpiScale;
//Debug.Log($"Screen DPI: {Screen.dpi}, DPI Scale: {dpiScale}, Adjusted Turn Acceleration: {turnAccelerationDPI}");
SetCursor(controlOptions.HasFlag(ControlOptions.MouseSteer));
characterController.enabled = true;
this.enabled = true;
}
public override void OnStopAuthority()
{
this.enabled = false;
characterController.enabled = false;
SetCursor(false);
}
public override void OnStartLocalPlayer()
{
if (ControllerUIPrefab != null)
controllerUI = Instantiate(ControllerUIPrefab);
if (controllerUI != null)
{
if (controllerUI.TryGetComponent(out PlayerControllerUI canvasControlPanel))
canvasControlPanel.Refresh(moveKeys, optionsKeys);
controllerUI.SetActive(controlOptions.HasFlag(ControlOptions.ShowUI));
}
}
public override void OnStopLocalPlayer()
{
if (controllerUI != null)
Destroy(controllerUI);
controllerUI = null;
}
#endregion
void Update()
{
if (!characterController.enabled)
return;
float deltaTime = Time.deltaTime;
HandleOptions();
if (controlOptions.HasFlag(ControlOptions.MouseSteer))
HandleMouseSteer(deltaTime);
else
HandleTurning(deltaTime);
HandleJumping(deltaTime);
HandleMove(deltaTime);
ApplyMove(deltaTime);
// Reset ground state
if (characterController.isGrounded)
groundState = GroundState.Grounded;
else if (groundState != GroundState.Jumping)
groundState = GroundState.Falling;
// Diagnostic velocity...FloorToInt for display purposes
velocity = Vector3Int.FloorToInt(characterController.velocity);
}
void SetCursor(bool locked)
{
Cursor.lockState = locked ? CursorLockMode.Locked : CursorLockMode.None;
Cursor.visible = !locked;
}
void HandleOptions()
{
if (optionsKeys.MouseSteer != KeyCode.None && Input.GetKeyUp(optionsKeys.MouseSteer))
{
controlOptions ^= ControlOptions.MouseSteer;
SetCursor(controlOptions.HasFlag(ControlOptions.MouseSteer));
}
if (optionsKeys.AutoRun != KeyCode.None && Input.GetKeyUp(optionsKeys.AutoRun))
controlOptions ^= ControlOptions.AutoRun;
if (optionsKeys.ToggleUI != KeyCode.None && Input.GetKeyUp(optionsKeys.ToggleUI))
{
controlOptions ^= ControlOptions.ShowUI;
if (controllerUI != null)
controllerUI.SetActive(controlOptions.HasFlag(ControlOptions.ShowUI));
}
}
// Turning works while airborne...feature?
void HandleTurning(float deltaTime)
{
float targetTurnSpeed = 0f;
// Q and E cancel each other out, reducing targetTurnSpeed to zero.
if (moveKeys.TurnLeft != KeyCode.None && Input.GetKey(moveKeys.TurnLeft))
targetTurnSpeed -= maxTurnSpeed;
if (moveKeys.TurnRight != KeyCode.None && Input.GetKey(moveKeys.TurnRight))
targetTurnSpeed += maxTurnSpeed;
turnSpeed = Mathf.MoveTowards(turnSpeed, targetTurnSpeed, turnAcceleration * maxTurnSpeed * deltaTime);
transform.Rotate(0f, turnSpeed * deltaTime, 0f);
}
void HandleMouseSteer(float deltaTime)
{
// Accumulate mouse input over time
mouseInputX += Input.GetAxisRaw("Mouse X") * mouseSensitivity;
// Clamp the accumulator to simulate key press behavior
mouseInputX = Mathf.Clamp(mouseInputX, -1f, 1f);
// Calculate target turn speed
float targetTurnSpeed = mouseInputX * maxTurnSpeed;
// Use the same acceleration logic as HandleTurning
turnSpeed = Mathf.MoveTowards(turnSpeed, targetTurnSpeed, mouseSensitivity * maxTurnSpeed * deltaTime);
// Apply rotation
transform.Rotate(0f, turnSpeed * deltaTime, 0f);
// Decay the accumulator over time
//float decayRate = 5f; // Adjust as needed
//mouseInputX = Mathf.MoveTowards(mouseInputX, 0f, decayRate * deltaTime);
mouseInputX = Mathf.MoveTowards(mouseInputX, 0f, mouseSensitivity * deltaTime);
}
void HandleJumping(float deltaTime)
{
if (groundState != GroundState.Falling && moveKeys.Jump != KeyCode.None && Input.GetKey(moveKeys.Jump))
{
if (groundState != GroundState.Jumping)
{
groundState = GroundState.Jumping;
jumpSpeed = initialJumpSpeed;
}
else if (jumpSpeed < maxJumpSpeed)
{
// Increase jumpSpeed using a square root function for a fast start and slow finish
float jumpProgress = (jumpSpeed - initialJumpSpeed) / (maxJumpSpeed - initialJumpSpeed);
jumpSpeed += (jumpAcceleration * Mathf.Sqrt(1 - jumpProgress)) * deltaTime;
}
if (jumpSpeed >= maxJumpSpeed)
{
jumpSpeed = maxJumpSpeed;
groundState = GroundState.Falling;
}
}
else if (groundState != GroundState.Grounded)
{
groundState = GroundState.Falling;
jumpSpeed = Mathf.Min(jumpSpeed, maxJumpSpeed);
jumpSpeed += Physics.gravity.y * deltaTime;
}
else
// maintain small downward speed for when falling off ledges
jumpSpeed = Physics.gravity.y * deltaTime;
}
void HandleMove(float deltaTime)
{
// Initialize target movement variables
float targetMoveX = 0f;
float targetMoveZ = 0f;
// Check for WASD key presses and adjust target movement variables accordingly
if (moveKeys.Forward != KeyCode.None && Input.GetKey(moveKeys.Forward)) targetMoveZ = 1f;
if (moveKeys.Back != KeyCode.None && Input.GetKey(moveKeys.Back)) targetMoveZ = -1f;
if (moveKeys.StrafeLeft != KeyCode.None && Input.GetKey(moveKeys.StrafeLeft)) targetMoveX = -1f;
if (moveKeys.StrafeRight != KeyCode.None && Input.GetKey(moveKeys.StrafeRight)) targetMoveX = 1f;
if (targetMoveX == 0f)
{
if (!controlOptions.HasFlag(ControlOptions.AutoRun))
horizontal = Mathf.MoveTowards(horizontal, targetMoveX, inputGravity * deltaTime);
}
else
horizontal = Mathf.MoveTowards(horizontal, targetMoveX, inputSensitivity * deltaTime);
if (targetMoveZ == 0f)
{
if (!controlOptions.HasFlag(ControlOptions.AutoRun))
vertical = Mathf.MoveTowards(vertical, targetMoveZ, inputGravity * deltaTime);
}
else
vertical = Mathf.MoveTowards(vertical, targetMoveZ, inputSensitivity * deltaTime);
}
void ApplyMove(float deltaTime)
{
// Create initial direction vector without jumpSpeed (y-axis).
direction = new Vector3(horizontal, 0f, vertical);
// Clamp so diagonal strafing isn't a speed advantage.
direction = Vector3.ClampMagnitude(direction, 1f);
// Transforms direction from local space to world space.
direction = transform.TransformDirection(direction);
// Multiply for desired ground speed.
direction *= maxMoveSpeed;
// Add jumpSpeed to direction as last step.
direction.y = jumpSpeed;
// Finally move the character.
characterController.Move(direction * deltaTime);
}
}
}

View File

@ -1,11 +1,11 @@
fileFormatVersion: 2
guid: 24fd13686a451ad498101a604d134e39
guid: 9e212b6697536124ca0e7791fe5d8d6b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,51 @@
using System;
using UnityEngine;
using UnityEngine.UI;
namespace Mirror.Examples.Common.Controllers.Player
{
[AddComponentMenu("")]
[DisallowMultipleComponent]
public class PlayerControllerUI : ContollerUIBase
{
[Serializable]
public struct MoveTexts
{
public Text keyTextTurnLeft;
public Text keyTextForward;
public Text keyTextTurnRight;
public Text keyTextStrafeLeft;
public Text keyTextBack;
public Text keyTextStrafeRight;
public Text keyTextJump;
}
[Serializable]
public struct OptionsTexts
{
public Text keyTextMouseSteer;
public Text keyTextAutoRun;
public Text keyTextToggleUI;
}
[SerializeField] MoveTexts moveTexts;
[SerializeField] OptionsTexts optionsTexts;
public void Refresh(PlayerController.MoveKeys moveKeys, PlayerController.OptionsKeys optionsKeys)
{
// Movement Keys
moveTexts.keyTextTurnLeft.text = GetKeyText(moveKeys.TurnLeft);
moveTexts.keyTextForward.text = GetKeyText(moveKeys.Forward);
moveTexts.keyTextTurnRight.text = GetKeyText(moveKeys.TurnRight);
moveTexts.keyTextStrafeLeft.text = GetKeyText(moveKeys.StrafeLeft);
moveTexts.keyTextBack.text = GetKeyText(moveKeys.Back);
moveTexts.keyTextStrafeRight.text = GetKeyText(moveKeys.StrafeRight);
moveTexts.keyTextJump.text = GetKeyText(moveKeys.Jump);
// Options Keys
optionsTexts.keyTextMouseSteer.text = GetKeyText(optionsKeys.MouseSteer);
optionsTexts.keyTextAutoRun.text = GetKeyText(optionsKeys.AutoRun);
optionsTexts.keyTextToggleUI.text = GetKeyText(optionsKeys.ToggleUI);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5548caf5abf51449f98ab54971eeff29
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 7beee247444994f0281dadde274cc4af
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 900b1db22b186f84cba696f403f120e2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,311 @@
using System;
using UnityEngine;
using UnityEngine.Serialization;
namespace Mirror.Examples.Common.Controllers.Tank
{
[AddComponentMenu("")]
[RequireComponent(typeof(PlayerCamera))]
[RequireComponent(typeof(Rigidbody))]
[RequireComponent(typeof(CharacterController))]
[RequireComponent(typeof(NetworkIdentity))]
[RequireComponent(typeof(NetworkTransformReliable))]
[DisallowMultipleComponent]
public class TankController : NetworkBehaviour
{
public enum GroundState : byte { Jumping, Falling, Grounded }
[Serializable]
public struct MoveKeys
{
public KeyCode Forward;
public KeyCode Back;
public KeyCode TurnLeft;
public KeyCode TurnRight;
}
[Serializable]
public struct OptionsKeys
{
public KeyCode AutoRun;
public KeyCode ToggleUI;
}
[Flags]
public enum ControlOptions : byte
{
None,
AutoRun = 1 << 0,
ShowUI = 1 << 1
}
[Header("Components")]
public BoxCollider boxCollider;
public CharacterController characterController;
public NetworkTransformReliable tankNTR;
[Header("User Interface")]
public GameObject ControllerUIPrefab;
[Header("Configuration")]
[SerializeField]
public MoveKeys moveKeys = new MoveKeys
{
Forward = KeyCode.W,
Back = KeyCode.S,
TurnLeft = KeyCode.A,
TurnRight = KeyCode.D,
};
[SerializeField]
public OptionsKeys optionsKeys = new OptionsKeys
{
AutoRun = KeyCode.R,
ToggleUI = KeyCode.U
};
[Space(5)]
public ControlOptions controlOptions = ControlOptions.ShowUI;
[Header("Movement")]
[Range(0, 20)]
[FormerlySerializedAs("moveSpeedMultiplier")]
[Tooltip("Speed in meters per second")]
public float maxMoveSpeed = 5f;
// Replacement for Sensitvity from Input Settings.
[Range(0, 10f)]
[Tooltip("Sensitivity factors into accelleration")]
public float inputSensitivity = 2f;
// Replacement for Gravity from Input Settings.
[Range(0, 10f)]
[Tooltip("Gravity factors into decelleration")]
public float inputGravity = 2f;
[Header("Turning")]
[Range(0, 300f)]
[Tooltip("Max Rotation in degrees per second")]
public float maxTurnSpeed = 100f;
[Range(0, 10f)]
[FormerlySerializedAs("turnDelta")]
[Tooltip("Rotation acceleration in degrees per second squared")]
public float turnAcceleration = 3f;
[Header("Diagnostics")]
[ReadOnly, SerializeField]
GroundState groundState = GroundState.Grounded;
[ReadOnly, SerializeField, Range(-1f, 1f)]
float horizontal;
[ReadOnly, SerializeField, Range(-1f, 1f)]
float vertical;
[ReadOnly, SerializeField, Range(-300f, 300f)]
float turnSpeed;
[ReadOnly, SerializeField, Range(-1.5f, 1.5f)]
float animVelocity;
[ReadOnly, SerializeField, Range(-1.5f, 1.5f)]
float animRotation;
[ReadOnly, SerializeField]
Vector3 direction;
[ReadOnly, SerializeField]
Vector3Int velocity;
[ReadOnly, SerializeField]
GameObject controllerUI;
#region Network Setup
protected override void OnValidate()
{
// Skip if Editor is in Play mode
if (Application.isPlaying) return;
base.OnValidate();
Reset();
}
void Reset()
{
if (boxCollider == null)
boxCollider = GetComponentInChildren<BoxCollider>();
// Enable by default...it will be disabled when characterController is enabled
boxCollider.enabled = true;
if (characterController == null)
characterController = GetComponent<CharacterController>();
// Override CharacterController default values
characterController.enabled = false;
characterController.skinWidth = 0.02f;
characterController.minMoveDistance = 0f;
GetComponent<Rigidbody>().isKinematic = true;
tankNTR = GetComponent<NetworkTransformReliable>();
tankNTR.compressRotation = false;
#if UNITY_EDITOR
// For convenience in the examples, we use the GUID of the TankControllerUI prefab
// to find the correct prefab in the Mirror/Examples/_Common/Controllers folder.
// This avoids conflicts with user-created prefabs that may have the same name
// and avoids polluting the user's project with Resources.
// This is not recommended for production code...use Resources.Load or AssetBundles instead.
if (ControllerUIPrefab == null)
{
string path = UnityEditor.AssetDatabase.GUIDToAssetPath("e64b14552402f6745a7f0aca6237fae2");
ControllerUIPrefab = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(path);
}
#endif
this.enabled = false;
}
public override void OnStartAuthority()
{
// capsuleCollider and characterController are mutually exclusive
// Having both enabled would double fire triggers and other collisions
//boxCollider.enabled = false;
characterController.enabled = true;
this.enabled = true;
}
public override void OnStopAuthority()
{
this.enabled = false;
// capsuleCollider and characterController are mutually exclusive
// Having both enabled would double fire triggers and other collisions
//boxCollider.enabled = true;
characterController.enabled = false;
}
public override void OnStartLocalPlayer()
{
if (ControllerUIPrefab != null)
controllerUI = Instantiate(ControllerUIPrefab);
if (controllerUI != null)
{
if (controllerUI.TryGetComponent(out TankControllerUI canvasControlPanel))
canvasControlPanel.Refresh(moveKeys, optionsKeys);
controllerUI.SetActive(controlOptions.HasFlag(ControlOptions.ShowUI));
}
}
public override void OnStopLocalPlayer()
{
if (controllerUI != null)
Destroy(controllerUI);
controllerUI = null;
}
#endregion
void Update()
{
if (!characterController.enabled)
return;
float deltaTime = Time.deltaTime;
HandleOptions();
HandleTurning(deltaTime);
HandleMove(deltaTime);
ApplyMove(deltaTime);
// Reset ground state
if (characterController.isGrounded)
groundState = GroundState.Grounded;
else if (groundState != GroundState.Jumping)
groundState = GroundState.Falling;
// Diagnostic velocity...FloorToInt for display purposes
velocity = Vector3Int.FloorToInt(characterController.velocity);
}
void HandleOptions()
{
if (optionsKeys.AutoRun != KeyCode.None && Input.GetKeyUp(optionsKeys.AutoRun))
controlOptions ^= ControlOptions.AutoRun;
if (optionsKeys.ToggleUI != KeyCode.None && Input.GetKeyUp(optionsKeys.ToggleUI))
{
controlOptions ^= ControlOptions.ShowUI;
if (controllerUI != null)
controllerUI.SetActive(controlOptions.HasFlag(ControlOptions.ShowUI));
}
}
// Turning works while airborne...feature?
void HandleTurning(float deltaTime)
{
float targetTurnSpeed = 0f;
// Q and E cancel each other out, reducing targetTurnSpeed to zero.
if (moveKeys.TurnLeft != KeyCode.None && Input.GetKey(moveKeys.TurnLeft))
targetTurnSpeed -= maxTurnSpeed;
if (moveKeys.TurnRight != KeyCode.None && Input.GetKey(moveKeys.TurnRight))
targetTurnSpeed += maxTurnSpeed;
turnSpeed = Mathf.MoveTowards(turnSpeed, targetTurnSpeed, turnAcceleration * maxTurnSpeed * deltaTime);
transform.Rotate(0f, turnSpeed * deltaTime, 0f);
}
void HandleMove(float deltaTime)
{
// Initialize target movement variables
float targetMoveX = 0f;
float targetMoveZ = 0f;
// Check for WASD key presses and adjust target movement variables accordingly
if (moveKeys.Forward != KeyCode.None && Input.GetKey(moveKeys.Forward)) targetMoveZ = 1f;
if (moveKeys.Back != KeyCode.None && Input.GetKey(moveKeys.Back)) targetMoveZ = -1f;
if (targetMoveX == 0f)
{
if (!controlOptions.HasFlag(ControlOptions.AutoRun))
horizontal = Mathf.MoveTowards(horizontal, targetMoveX, inputGravity * deltaTime);
}
else
horizontal = Mathf.MoveTowards(horizontal, targetMoveX, inputSensitivity * deltaTime);
if (targetMoveZ == 0f)
{
if (!controlOptions.HasFlag(ControlOptions.AutoRun))
vertical = Mathf.MoveTowards(vertical, targetMoveZ, inputGravity * deltaTime);
}
else
vertical = Mathf.MoveTowards(vertical, targetMoveZ, inputSensitivity * deltaTime);
}
void ApplyMove(float deltaTime)
{
// Create initial direction vector without jumpSpeed (y-axis).
direction = new Vector3(horizontal, 0f, vertical);
// Clamp so diagonal strafing isn't a speed advantage.
direction = Vector3.ClampMagnitude(direction, 1f);
// Transforms direction from local space to world space.
direction = transform.TransformDirection(direction);
// Multiply for desired ground speed.
direction *= maxMoveSpeed;
// Add gravity in case we drove off a cliff.
direction += Physics.gravity;
// Finally move the character.
characterController.Move(direction * deltaTime);
}
}
}

View File

@ -1,11 +1,11 @@
fileFormatVersion: 2
guid: 015c43bd22cae4d79946c0e37c1bb8b1
guid: 047024b2ae9afb74485837a482ea4175
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,54 @@
using System;
using UnityEngine;
using UnityEngine.UI;
namespace Mirror.Examples.Common.Controllers.Tank
{
[AddComponentMenu("")]
[DisallowMultipleComponent]
public class TankControllerUI : ContollerUIBase
{
[Serializable]
public struct MoveTexts
{
public Text keyTextTurnLeft;
public Text keyTextForward;
public Text keyTextTurnRight;
public Text keyTextBack;
public Text keyTextShoot;
}
public struct OtherTexts
{
public Text keyTextShoot;
}
[Serializable]
public struct OptionsTexts
{
public Text keyTextMouseLock;
public Text keyTextAutoRun;
public Text keyTextToggleUI;
}
[SerializeField] MoveTexts moveTexts;
[SerializeField] OtherTexts otherKeys;
[SerializeField] OptionsTexts optionsTexts;
public void Refresh(TankController.MoveKeys moveKeys, TankController.OptionsKeys optionsKeys)
{
// Movement Keys
moveTexts.keyTextTurnLeft.text = GetKeyText(moveKeys.TurnLeft);
moveTexts.keyTextForward.text = GetKeyText(moveKeys.Forward);
moveTexts.keyTextTurnRight.text = GetKeyText(moveKeys.TurnRight);
moveTexts.keyTextBack.text = GetKeyText(moveKeys.Back);
//// Other Keys
//moveTexts.keyTextShoot.text = GetKeyText(otherKeys.Shoot);
// Options Keys
optionsTexts.keyTextAutoRun.text = GetKeyText(optionsKeys.AutoRun);
optionsTexts.keyTextToggleUI.text = GetKeyText(optionsKeys.ToggleUI);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 55bd8eba9aaa3104d85d885bfa7f0437
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e64b14552402f6745a7f0aca6237fae2
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,82 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Mirror.Examples.Common.Controllers.Tank
{
[AddComponentMenu("")]
[DisallowMultipleComponent]
public class TankHealth : NetworkBehaviour
{
[Header("Components")]
public TextMesh healthBar;
[Header("Stats")]
public byte maxHealth = 5;
[SyncVar(hook = nameof(OnHealthChanged))]
public byte health = 5;
[Header("Respawn")]
public bool respawn = true;
public byte respawnTime = 3;
void OnHealthChanged(byte oldHealth, byte newHealth)
{
healthBar.text = new string('-', newHealth);
if (newHealth >= maxHealth)
healthBar.color = Color.green;
if (newHealth < 4)
healthBar.color = Color.yellow;
if (newHealth < 2)
healthBar.color = Color.red;
if (newHealth <= 0)
healthBar.color = Color.black;
}
#region Unity Callbacks
protected override void OnValidate()
{
// Skip if Editor is in Play mode
if (Application.isPlaying) return;
base.OnValidate();
Reset();
}
public void Reset()
{
if (healthBar == null)
healthBar = GetComponentInChildren<TextMesh>();
}
#endregion
public override void OnStartServer()
{
health = maxHealth;
}
[ServerCallback]
public void TakeDamage(byte damage)
{
// Skip if health is already 0
if (health <= 0) return;
health -= damage;
if (health <= 0)
{
health = 0;
if (connectionToClient != null)
Respawn.RespawnPlayer(respawn, respawnTime, connectionToClient);
else if (netIdentity.sceneId != 0)
NetworkServer.UnSpawn(gameObject);
else
Destroy(gameObject);
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a98fd0a5ae4916d48bdcdb0e8c99a5cc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,482 @@
using System;
using UnityEngine;
namespace Mirror.Examples.Common.Controllers.Tank
{
[AddComponentMenu("")]
[RequireComponent(typeof(NetworkIdentity))]
[RequireComponent(typeof(NetworkTransformReliable))]
[RequireComponent(typeof(TankController))]
[DisallowMultipleComponent]
public class TankTurret : NetworkBehaviour
{
[Serializable]
public struct OptionsKeys
{
public KeyCode MouseLock;
public KeyCode AutoLevel;
public KeyCode ToggleUI;
}
[Serializable]
public struct MoveKeys
{
public KeyCode PitchUp;
public KeyCode PitchDown;
public KeyCode TurnLeft;
public KeyCode TurnRight;
}
[Serializable]
public struct OtherKeys
{
public KeyCode Shoot;
}
const float BASE_DPI = 96f;
[Flags]
public enum ControlOptions : byte
{
None,
MouseLock = 1 << 0,
AutoLevel = 1 << 1,
ShowUI = 1 << 2
}
// Unity clones the material when GetComponent<Renderer>().material is called
// Cache it here and destroy it in OnDestroy to prevent a memory leak
Material cachedMaterial;
[Header("Prefabs")]
public GameObject TurretUIPrefab;
public GameObject projectilePrefab;
[Header("Components")]
public Animator animator;
public NetworkTransformReliable turretNTR;
public NetworkTransformReliable barrelNTR;
public Transform turret;
public Transform barrel;
public Transform projectileMount;
[Header("Seated Player")]
public GameObject playerObject;
[SyncVar(hook = nameof(OnPlayerColorChanged))]
public Color32 playerColor = Color.black;
[Header("Configuration")]
[SerializeField]
public MoveKeys moveKeys = new MoveKeys
{
PitchUp = KeyCode.UpArrow,
PitchDown = KeyCode.DownArrow,
TurnLeft = KeyCode.LeftArrow,
TurnRight = KeyCode.RightArrow
};
[SerializeField]
public OtherKeys otherKeys = new OtherKeys
{
Shoot = KeyCode.Space
};
[SerializeField]
public OptionsKeys optionsKeys = new OptionsKeys
{
MouseLock = KeyCode.M,
AutoLevel = KeyCode.L,
ToggleUI = KeyCode.U
};
[Space(5)]
public ControlOptions controlOptions = ControlOptions.AutoLevel | ControlOptions.ShowUI;
[Header("Turret")]
[Range(0, 300f)]
[Tooltip("Max Rotation in degrees per second")]
public float maxTurretSpeed = 250f;
[Range(0, 10f)]
[Tooltip("Rotation acceleration in degrees per second squared")]
public float turretAcceleration = 10f;
[Header("Barrel")]
[Range(0, 180f)]
[Tooltip("Max Pitch in degrees per second")]
public float maxPitchSpeed = 30f;
[Range(0, 40f)]
[Tooltip("Max Pitch in degrees")]
public float maxPitchUpAngle = 25f;
[Range(0, 20f)]
[Tooltip("Max Pitch in degrees")]
public float maxPitchDownAngle = 0f;
[Range(0, 10f)]
[Tooltip("Pitch acceleration in degrees per second squared")]
public float pitchAcceleration = 3f;
[Header("Diagnostics")]
[ReadOnly, SerializeField, Range(-1f, 1f)]
float mouseInputX;
[ReadOnly, SerializeField, Range(0, 30f)]
float mouseSensitivity;
[ReadOnly, SerializeField, Range(-300f, 300f)]
float turretSpeed;
[ReadOnly, SerializeField, Range(-180f, 180f)]
float pitchAngle;
[ReadOnly, SerializeField, Range(-180f, 180f)]
float pitchSpeed;
[ReadOnly, SerializeField]
GameObject turretUI;
void OnPlayerColorChanged(Color32 _, Color32 newColor)
{
if (cachedMaterial == null)
cachedMaterial = playerObject.GetComponent<Renderer>().material;
cachedMaterial.color = newColor;
playerObject.SetActive(newColor != Color.black);
}
#region Unity Callbacks
/// <summary>
/// Add your validation code here after the base.OnValidate(); call.
/// </summary>
protected override void OnValidate()
{
// Skip if Editor is in Play mode
if (Application.isPlaying) return;
base.OnValidate();
Reset();
}
// NOTE: Do not put objects in DontDestroyOnLoad (DDOL) in Awake. You can do that in Start instead.
void Reset()
{
if (animator == null)
animator = GetComponentInChildren<Animator>();
// Set default...this may be modified based on DPI at runtime
mouseSensitivity = turretAcceleration;
// Do a recursive search for a children named "Turret" and "ProjectileMount".
// They will be several levels deep in the hierarchy.
if (turret == null)
turret = FindDeepChild(transform, "Turret");
if (barrel == null)
barrel = FindDeepChild(turret, "Barrel");
if (projectileMount == null)
projectileMount = FindDeepChild(turret, "ProjectileMount");
if (playerObject == null)
playerObject = FindDeepChild(turret, "SeatedPlayer").gameObject;
// tranform.Find will fail - must do recursive search
Transform FindDeepChild(Transform aParent, string aName)
{
var result = aParent.Find(aName);
if (result != null)
return result;
foreach (Transform child in aParent)
{
result = FindDeepChild(child, aName);
if (result != null)
return result;
}
return null;
}
// The base Tank uses the first NetworkTransformReliable for the tank body
// Add additional NetworkTransformReliable components for the turret and barrel
// Set SyncPosition to false because we only want to sync rotation
NetworkTransformReliable[] NTRs = GetComponents<NetworkTransformReliable>();
if (NTRs.Length < 2)
{
turretNTR = gameObject.AddComponent<NetworkTransformReliable>();
turretNTR.transform.SetSiblingIndex(NTRs[0].transform.GetSiblingIndex() + 1);
NTRs = GetComponents<NetworkTransformReliable>();
}
else
turretNTR = NTRs[1];
// Ensure SyncDirection is Client to Server
turretNTR.syncDirection = SyncDirection.ClientToServer;
turretNTR.syncPosition = false;
turretNTR.compressRotation = false;
// Set SyncPosition to false because we only want to sync rotation
//turretNTR.syncPosition = false;
if (turret != null)
turretNTR.target = turret;
if (NTRs.Length < 3)
{
barrelNTR = gameObject.AddComponent<NetworkTransformReliable>();
barrelNTR.transform.SetSiblingIndex(NTRs[1].transform.GetSiblingIndex() + 1);
NTRs = GetComponents<NetworkTransformReliable>();
}
else
barrelNTR = NTRs[2];
// Ensure SyncDirection is Client to Server
barrelNTR.syncDirection = SyncDirection.ClientToServer;
barrelNTR.syncPosition = false;
barrelNTR.compressRotation = false;
// Set SyncPosition to false because we only want to sync rotation
//barrelNTR.syncPosition = false;
if (barrel != null)
barrelNTR.target = barrel;
#if UNITY_EDITOR
// For convenience in the examples, we use the GUID of the Projectile prefab
// to find the correct prefab in the Mirror/Examples/_Common/Controllers folder.
// This avoids conflicts with user-created prefabs that may have the same name
// and avoids polluting the user's project with Resources.
// This is not recommended for production code...use Resources.Load or AssetBundles instead.
if (TurretUIPrefab == null)
{
string path = UnityEditor.AssetDatabase.GUIDToAssetPath("4d16730f7a8ba0a419530d1156d25080");
TurretUIPrefab = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(path);
}
if (projectilePrefab == null)
{
string path = UnityEditor.AssetDatabase.GUIDToAssetPath("aec853915cd4f4477ba1532b5fe05488");
projectilePrefab = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(path);
}
#endif
this.enabled = false;
}
#endregion
void Update()
{
float deltaTime = Time.deltaTime;
HandleOptions();
HandlePitch(deltaTime);
if (controlOptions.HasFlag(ControlOptions.MouseLock))
HandleMouseTurret(deltaTime);
else
HandleTurning(deltaTime);
HandleShooting();
}
void SetCursor(bool locked)
{
Cursor.lockState = locked ? CursorLockMode.Locked : CursorLockMode.None;
Cursor.visible = !locked;
}
void HandleOptions()
{
if (optionsKeys.MouseLock != KeyCode.None && Input.GetKeyUp(optionsKeys.MouseLock))
{
controlOptions ^= ControlOptions.MouseLock;
SetCursor(controlOptions.HasFlag(ControlOptions.MouseLock));
}
if (optionsKeys.AutoLevel != KeyCode.None && Input.GetKeyUp(optionsKeys.AutoLevel))
controlOptions ^= ControlOptions.AutoLevel;
if (optionsKeys.ToggleUI != KeyCode.None && Input.GetKeyUp(optionsKeys.ToggleUI))
{
controlOptions ^= ControlOptions.ShowUI;
if (turretUI != null)
turretUI.SetActive(controlOptions.HasFlag(ControlOptions.ShowUI));
}
}
void HandleTurning(float deltaTime)
{
float targetTurnSpeed = 0f;
// Q and E cancel each other out, reducing targetTurnSpeed to zero.
if (moveKeys.TurnLeft != KeyCode.None && Input.GetKey(moveKeys.TurnLeft))
targetTurnSpeed -= maxTurretSpeed;
if (moveKeys.TurnRight != KeyCode.None && Input.GetKey(moveKeys.TurnRight))
targetTurnSpeed += maxTurretSpeed;
turretSpeed = Mathf.MoveTowards(turretSpeed, targetTurnSpeed, turretAcceleration * maxTurretSpeed * deltaTime);
turret.Rotate(0f, turretSpeed * deltaTime, 0f);
}
void HandleMouseTurret(float deltaTime)
{
// Accumulate mouse input over time
mouseInputX += Input.GetAxisRaw("Mouse X") * mouseSensitivity;
// Clamp the accumulator to simulate key press behavior
mouseInputX = Mathf.Clamp(mouseInputX, -1f, 1f);
// Calculate target turn speed
float targetTurnSpeed = mouseInputX * maxTurretSpeed;
// Use the same acceleration logic as HandleTurning
turretSpeed = Mathf.MoveTowards(turretSpeed, targetTurnSpeed, mouseSensitivity * maxTurretSpeed * deltaTime);
// Apply rotation
turret.Rotate(0f, turretSpeed * deltaTime, 0f);
// Decay the accumulator over time
//float decayRate = 5f; // Adjust as needed
//mouseInputX = Mathf.MoveTowards(mouseInputX, 0f, decayRate * deltaTime);
mouseInputX = Mathf.MoveTowards(mouseInputX, 0f, mouseSensitivity * deltaTime);
}
void HandlePitch(float deltaTime)
{
float targetPitchSpeed = 0f;
bool inputDetected = false;
// Up and Down arrows for pitch
if (moveKeys.PitchUp != KeyCode.None && Input.GetKey(moveKeys.PitchUp))
{
targetPitchSpeed -= maxPitchSpeed;
inputDetected = true;
}
if (moveKeys.PitchDown != KeyCode.None && Input.GetKey(moveKeys.PitchDown))
{
targetPitchSpeed += maxPitchSpeed;
inputDetected = true;
}
pitchSpeed = Mathf.MoveTowards(pitchSpeed, targetPitchSpeed, pitchAcceleration * maxPitchSpeed * deltaTime);
// Apply pitch rotation
pitchAngle += pitchSpeed * deltaTime;
pitchAngle = Mathf.Clamp(pitchAngle, -maxPitchUpAngle, maxPitchDownAngle);
// Return to -90 when no input
if (!inputDetected && controlOptions.HasFlag(ControlOptions.AutoLevel))
pitchAngle = Mathf.MoveTowards(pitchAngle, 0f, maxPitchSpeed * deltaTime);
// Apply rotation to barrel -- rotation is (-90, 0, 180) in the prefab
// so that's what we have to work towards.
barrel.localRotation = Quaternion.Euler(-90f + pitchAngle, 0f, 180f);
}
#region Shooting
void HandleShooting()
{
if (otherKeys.Shoot != KeyCode.None && Input.GetKeyUp(otherKeys.Shoot))
{
CmdShoot();
if (!isServer) DoShoot();
}
}
[Command]
void CmdShoot()
{
//Debug.Log("CmdShoot");
RpcShoot();
DoShoot();
}
[ClientRpc(includeOwner = false)]
void RpcShoot()
{
//Debug.Log("RpcShoot");
if (!isServer) DoShoot();
}
// This has multiple callers in different contexts...don't consolidate, even if it looks like you could.
void DoShoot()
{
//Debug.Log($"DoShoot isServerOnly:{isServerOnly} | isServer:{isServer} | isClient:{isClient}");
// Turret
// - Barrel (with Collider)
// - BarrelEnd
// - ProjectileMount
// projectileMount.transform.parent.parent is the Barrel object with the Collider
if (isServerOnly)
{
// Dedicated Server logic - no host client
GameObject go = Instantiate(projectilePrefab, projectileMount.position, projectileMount.rotation);
Physics.IgnoreCollision(go.GetComponent<Collider>(), projectileMount.transform.parent.parent.GetComponent<Collider>());
}
else if (isServer)
{
// Server logic, including host client
//animator.SetTrigger("Shoot");
GameObject go = Instantiate(projectilePrefab, projectileMount.position, projectileMount.rotation);
Physics.IgnoreCollision(go.GetComponent<Collider>(), projectileMount.transform.parent.parent.GetComponent<Collider>());
}
if (isClientOnly)
{
// Client-side logic, excluding host client
//animator.SetTrigger("Shoot");
GameObject go = Instantiate(projectilePrefab, projectileMount.position, projectileMount.rotation);
Physics.IgnoreCollision(go.GetComponent<Collider>(), projectileMount.transform.parent.parent.GetComponent<Collider>());
}
}
#endregion
#region Start & Stop Callbacks
public override void OnStartServer() { }
public override void OnStartLocalPlayer()
{
if (TurretUIPrefab != null)
turretUI = Instantiate(TurretUIPrefab);
if (turretUI != null)
{
if (turretUI.TryGetComponent(out TurretUI canvasControlPanel))
canvasControlPanel.Refresh(moveKeys, optionsKeys);
turretUI.SetActive(controlOptions.HasFlag(ControlOptions.ShowUI));
}
}
public override void OnStopLocalPlayer()
{
if (turretUI != null)
Destroy(turretUI);
turretUI = null;
}
public override void OnStartAuthority()
{
// Calculate DPI-aware sensitivity
float dpiScale = (Screen.dpi > 0) ? (Screen.dpi / BASE_DPI) : 1f;
mouseSensitivity = turretAcceleration * dpiScale;
//Debug.Log($"Screen DPI: {Screen.dpi}, DPI Scale: {dpiScale}, Adjusted Turn Acceleration: {turnAccelerationDPI}");
SetCursor(controlOptions.HasFlag(ControlOptions.MouseLock));
this.enabled = true;
}
public override void OnStopAuthority()
{
SetCursor(false);
this.enabled = false;
}
#endregion
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2620edb022743ce4bafb12274ee78716
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,31 @@
using System;
using UnityEngine;
using UnityEngine.UI;
namespace Mirror.Examples.Common.Controllers.Tank
{
[AddComponentMenu("")]
[DisallowMultipleComponent]
public class TurretUI : ContollerUIBase
{
[Serializable]
public struct MoveTexts
{
public Text keyTextPitchUp;
public Text keyTextPitchDown;
public Text keyTextTurnLeft;
public Text keyTextTurnRight;
}
[SerializeField] MoveTexts moveTexts;
public void Refresh(TankTurret.MoveKeys moveKeys, TankTurret.OptionsKeys optionsKeys)
{
// Movement Keys
moveTexts.keyTextPitchUp.text = GetKeyText(moveKeys.PitchUp);
moveTexts.keyTextPitchDown.text = GetKeyText(moveKeys.PitchDown);
moveTexts.keyTextTurnLeft.text = GetKeyText(moveKeys.TurnLeft);
moveTexts.keyTextTurnRight.text = GetKeyText(moveKeys.TurnRight);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 727f1d4c7bded434bb0a729ba0dcbc51
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4d16730f7a8ba0a419530d1156d25080
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0f549f9421a9ab44894b760a3fecbe2d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 238d02181d5de8e48b9e206f81fda56f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,58 @@
using UnityEngine;
namespace Mirror.Examples.Common
{
[AddComponentMenu("")]
[RequireComponent(typeof(Rigidbody))]
[RequireComponent(typeof(CapsuleCollider))]
[DisallowMultipleComponent]
public class TankProjectile : MonoBehaviour
{
[Header("Components")]
public Rigidbody rigidBody;
public CapsuleCollider capsuleCollider;
[Header("Settings")]
public float destroyAfter = 3f;
public float force = 1000f;
enum CapsuleColliderDirection { XAxis, YAxis, ZAxis }
void OnValidate()
{
if (Application.isPlaying) return;
Reset();
}
void Reset()
{
rigidBody = GetComponent<Rigidbody>();
rigidBody.useGravity = false;
rigidBody.collisionDetectionMode = CollisionDetectionMode.Continuous;
rigidBody.constraints = RigidbodyConstraints.FreezeRotation;
capsuleCollider = GetComponent<CapsuleCollider>();
capsuleCollider.direction = (int)CapsuleColliderDirection.ZAxis;
capsuleCollider.radius = 0.1f;
capsuleCollider.height = 0.4f;
}
// set velocity for server and client. this way we don't have to sync the
// position, because both the server and the client simulate it.
void Start()
{
rigidBody.AddForce(transform.forward * force);
Destroy(gameObject, destroyAfter);
}
private void OnCollisionEnter(Collision collision)
{
//Debug.Log($"Hit: {collision.gameObject}");
if (NetworkServer.active && collision.gameObject.TryGetComponent(out Controllers.Tank.TankHealth tankHealth))
tankHealth.TakeDamage(1);
Destroy(gameObject);
}
}
}

View File

@ -5,7 +5,7 @@ MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -7,7 +7,7 @@ Material:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: ProjectileMaterial
m_Name: TankProjectile
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4

View File

@ -25,13 +25,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 63476987332307980}
serializedVersion: 2
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.05, y: 0.1, z: 0.05}
m_LocalScale: {x: 0.2, y: 0.2, z: 0.2}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 24373266488650541}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
--- !u!33 &9118274893554935717
MeshFilter:
@ -92,12 +92,11 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 24373266488650541}
- component: {fileID: 1713098107664522388}
- component: {fileID: 2355290524794870353}
- component: {fileID: 4629190479245867726}
- component: {fileID: 2355290524794870353}
- component: {fileID: -6445143729112923095}
m_Layer: 0
m_Name: Projectile
m_Name: TankProjectile
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -110,6 +109,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5890560936853567077}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
@ -117,25 +117,34 @@ Transform:
m_Children:
- {fileID: 8035186136109819211}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1713098107664522388
MonoBehaviour:
--- !u!54 &4629190479245867726
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5890560936853567077}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9b91ecbcc199f4492b9a91e820070131, type: 3}
m_Name:
m_EditorClassIdentifier:
sceneId: 0
_assetId: 4186459745
serverOnly: 0
visible: 0
hasSpawned: 0
serializedVersion: 4
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_CenterOfMass: {x: 0, y: 0, z: 0}
m_InertiaTensor: {x: 1, y: 1, z: 1}
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_ImplicitCom: 1
m_ImplicitTensor: 1
m_UseGravity: 0
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 112
m_CollisionDetection: 1
--- !u!136 &2355290524794870353
CapsuleCollider:
m_ObjectHideFlags: 0
@ -144,28 +153,21 @@ CapsuleCollider:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5890560936853567077}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
m_Radius: 0.05
m_Height: 0.2
m_Direction: 1
m_Center: {x: 0, y: 0, z: 0}
--- !u!54 &4629190479245867726
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5890560936853567077}
m_IncludeLayers:
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 0
m_IsKinematic: 0
m_Interpolate: 1
m_Constraints: 0
m_CollisionDetection: 1
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.1
m_Height: 0.4
m_Direction: 2
m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &-6445143729112923095
MonoBehaviour:
m_ObjectHideFlags: 0
@ -178,9 +180,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 9b0798e773349420dbdf4ee305445d6b, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 0
syncMode: 0
syncInterval: 0
destroyAfter: 2
rigidBody: {fileID: 4629190479245867726}
force: 800
capsuleCollider: {fileID: 2355290524794870353}
destroyAfter: 3
force: 1000

View File

@ -32,7 +32,7 @@ protected void OnGUI()
{
if (!showGUI) return;
GUI.Label(new Rect(Screen.width - 70, 0, 70, 25), $"FPS: {framesPerSecond}");
GUI.Label(new Rect(Screen.width - 100, 0, 70, 25), $"FPS: {framesPerSecond}");
}
}
}

View File

@ -6,15 +6,24 @@
namespace Mirror.Examples.Common
{
[AddComponentMenu("")]
[DisallowMultipleComponent]
public class PlayerCamera : NetworkBehaviour
{
Camera mainCam;
public Vector3 offset = new Vector3(0f, 3f, -8f);
public Vector3 rotation = new Vector3(10f, 0f, 0f);
void Awake()
{
mainCam = Camera.main;
}
void OnDisable()
{
//Debug.Log("PlayerCamera.OnDisable");
}
public override void OnStartLocalPlayer()
{
if (mainCam != null)
@ -22,8 +31,8 @@ public override void OnStartLocalPlayer()
// configure and make camera a child of player with 3rd person offset
mainCam.orthographic = false;
mainCam.transform.SetParent(transform);
mainCam.transform.localPosition = new Vector3(0f, 3f, -8f);
mainCam.transform.localEulerAngles = new Vector3(10f, 0f, 0f);
mainCam.transform.localPosition = offset;
mainCam.transform.localEulerAngles = rotation;
}
else
Debug.LogWarning("PlayerCamera: Could not find a camera in scene with 'MainCamera' tag.");
@ -31,7 +40,7 @@ public override void OnStartLocalPlayer()
public override void OnStopLocalPlayer()
{
if (mainCam != null)
if (mainCam != null && mainCam.transform.parent == transform)
{
mainCam.transform.SetParent(null);
SceneManager.MoveGameObjectToScene(mainCam.gameObject, SceneManager.GetActiveScene());

View File

@ -0,0 +1,47 @@
using System.Collections;
using UnityEngine;
namespace Mirror.Examples.Common
{
public class Respawn
{
public static void RespawnPlayer(bool respawn, byte respawnTime, NetworkConnectionToClient conn)
{
// Use the NetworkManager static singleton to start a coroutine
NetworkManager.singleton.StartCoroutine(DoRespawn(respawn, respawnTime, conn));
}
public static IEnumerator DoRespawn(bool respawn, byte respawnTime, NetworkConnectionToClient conn)
{
//Debug.Log("DoRespawn started");
// Wait for SyncVars to Update
yield return null;
// Remove Player
if (!respawn)
{
NetworkServer.RemovePlayerForConnection(conn, RemovePlayerOptions.Destroy);
//Debug.Log("Player destroyed");
yield break;
}
GameObject playerObject = conn.identity.gameObject;
NetworkServer.RemovePlayerForConnection(conn, RemovePlayerOptions.Unspawn);
//Debug.Log("Player unspawned");
// Wait for respawn Time
yield return new WaitForSeconds(respawnTime);
// Respawn Player - fallback to Vector3.up * 5f to avoid spawning on another player.
Transform spawnPoint = NetworkManager.singleton.GetStartPosition();
Vector3 position = spawnPoint != null ? spawnPoint.position : Vector3.up * 5f;
Quaternion rotation = spawnPoint != null ? spawnPoint.rotation : Quaternion.identity;
playerObject.transform.SetPositionAndRotation(position, rotation);
NetworkServer.AddPlayerForConnection(conn, playerObject);
//Debug.Log("Player respawned");
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 276ad7fee659190468450542a55f643c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More