From a566463e20df3e275e5e69f8062bbd5b4981dab3 Mon Sep 17 00:00:00 2001 From: JoshuaReason Date: Thu, 2 May 2019 12:26:26 +1000 Subject: [PATCH] Made players spawn in correct direction --- .../{Scripts/Components.meta => Models.meta} | 2 +- Assets/Plugins.meta | 8 +++++ Assets/Plugins/IngameDebugConsole.meta | 8 +++++ .../Plugins/IngameDebugConsole/Android.meta | 8 +++++ .../Plugins/IngameDebugConsole/Prefabs.meta | 8 +++++ .../Plugins/IngameDebugConsole/Scripts.meta | 8 +++++ .../Plugins/IngameDebugConsole/Sprites.meta | 8 +++++ .../IngameDebugConsole/Sprites/Unused.meta | 8 +++++ .../Server Scenes/ServerTestScene.unity | 17 +++++++++- Assets/Scripts/Block.cs | 31 +++++++++++++++++-- Assets/Scripts/LogicBlocks.meta | 8 +++++ Assets/Scripts/Managers/GameManager.cs | 3 +- 12 files changed, 112 insertions(+), 5 deletions(-) rename Assets/{Scripts/Components.meta => Models.meta} (77%) create mode 100644 Assets/Plugins.meta create mode 100644 Assets/Plugins/IngameDebugConsole.meta create mode 100644 Assets/Plugins/IngameDebugConsole/Android.meta create mode 100644 Assets/Plugins/IngameDebugConsole/Prefabs.meta create mode 100644 Assets/Plugins/IngameDebugConsole/Scripts.meta create mode 100644 Assets/Plugins/IngameDebugConsole/Sprites.meta create mode 100644 Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta create mode 100644 Assets/Scripts/LogicBlocks.meta diff --git a/Assets/Scripts/Components.meta b/Assets/Models.meta similarity index 77% rename from Assets/Scripts/Components.meta rename to Assets/Models.meta index 5a95b09..5346456 100644 --- a/Assets/Scripts/Components.meta +++ b/Assets/Models.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 8d7394d70ec233849a60a26da5f23b75 +guid: 296bd90e667df1f4697823a0aa45acf0 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/Plugins.meta b/Assets/Plugins.meta new file mode 100644 index 0000000..aa3b71c --- /dev/null +++ b/Assets/Plugins.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: eb6762a6d45772b43a77849ba46f89db +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/IngameDebugConsole.meta b/Assets/Plugins/IngameDebugConsole.meta new file mode 100644 index 0000000..36375af --- /dev/null +++ b/Assets/Plugins/IngameDebugConsole.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5f8eae876be4b03438375a82d2c69b4d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/IngameDebugConsole/Android.meta b/Assets/Plugins/IngameDebugConsole/Android.meta new file mode 100644 index 0000000..12049b6 --- /dev/null +++ b/Assets/Plugins/IngameDebugConsole/Android.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3d7d7a61a5341904eb3c65af025b1d86 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/IngameDebugConsole/Prefabs.meta b/Assets/Plugins/IngameDebugConsole/Prefabs.meta new file mode 100644 index 0000000..6aa8bf2 --- /dev/null +++ b/Assets/Plugins/IngameDebugConsole/Prefabs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7dbc36665bc0d684db9a4447e27a7a4b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/IngameDebugConsole/Scripts.meta b/Assets/Plugins/IngameDebugConsole/Scripts.meta new file mode 100644 index 0000000..72dcaac --- /dev/null +++ b/Assets/Plugins/IngameDebugConsole/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 860c08388401a6d4e858fe4910ea9337 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/IngameDebugConsole/Sprites.meta b/Assets/Plugins/IngameDebugConsole/Sprites.meta new file mode 100644 index 0000000..504a23d --- /dev/null +++ b/Assets/Plugins/IngameDebugConsole/Sprites.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cb5d7b23a9e684a41a6a5d4f300eb1e6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta b/Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta new file mode 100644 index 0000000..f3769b1 --- /dev/null +++ b/Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f6caae32d463529478f2186f47c2e3fe +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/Server Scenes/ServerTestScene.unity b/Assets/Scenes/Server Scenes/ServerTestScene.unity index 1764394..b12a8e3 100644 --- a/Assets/Scenes/Server Scenes/ServerTestScene.unity +++ b/Assets/Scenes/Server Scenes/ServerTestScene.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1} + m_IndirectSpecularColor: {r: 0.44657868, g: 0.49641263, b: 0.57481706, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -424,6 +424,11 @@ PrefabInstance: propertyPath: isSpawnable value: 1 objectReference: {fileID: 0} + - target: {fileID: 8101348915751558870, guid: d7698c69246c64044ab2a94628bf0291, + type: 3} + propertyPath: SpawnDirection + value: 3 + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: d7698c69246c64044ab2a94628bf0291, type: 3} --- !u!4 &308885819 stripped @@ -1780,6 +1785,11 @@ PrefabInstance: propertyPath: isSpawnable value: 1 objectReference: {fileID: 0} + - target: {fileID: 8101348915751558870, guid: d7698c69246c64044ab2a94628bf0291, + type: 3} + propertyPath: SpawnDirection + value: 0 + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: d7698c69246c64044ab2a94628bf0291, type: 3} --- !u!4 &1101212184 stripped @@ -1911,6 +1921,11 @@ PrefabInstance: propertyPath: isSpawnable value: 1 objectReference: {fileID: 0} + - target: {fileID: 8101348915751558870, guid: d7698c69246c64044ab2a94628bf0291, + type: 3} + propertyPath: SpawnDirection + value: 1 + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: d7698c69246c64044ab2a94628bf0291, type: 3} --- !u!4 &1437209178 stripped diff --git a/Assets/Scripts/Block.cs b/Assets/Scripts/Block.cs index 0e08cc5..fbe2e81 100644 --- a/Assets/Scripts/Block.cs +++ b/Assets/Scripts/Block.cs @@ -18,9 +18,12 @@ public class Block : MonoBehaviour [Tooltip("Can this type of block be walked on")] private bool _isWalkable = true; - [SerializeField] [Tooltip("Can this block be spawned on")] public bool isSpawnable = false; + + [Tooltip("Direction Player is poting at when spawned")] + public Direction SpawnDirection = Direction.Forward; + #endregion InspectorFields #region ReadOnly Properties @@ -45,10 +48,34 @@ public class Block : MonoBehaviour public bool isWalkable(LayerMask layerMask) { //checks if there is no block above this one and that this is tagged as walkable - return (_isWalkable && !isBlockAtPosition(position + Vector3.up, 1, layerMask)); + return (_isWalkable && !isBlockAtPosition(position + Vector3.up, 1, layerMask)); } #endregion Public Functions + private void OnDrawGizmos() + { + if (!isSpawnable) + return; + + Vector3 DrawPosition = VisualPosition + Vector3.up * 0.4f; + Vector3 Perp = Quaternion.Euler(0, 90, 0) * SpawnDirection.ToVector(); + + DebugExtensions.DrawCube(DrawPosition, 0.4f, Color.magenta, 0); + + //Eyes + Vector3 eyePosition = DrawPosition + SpawnDirection.ToVector() * 0.4f; + DebugExtensions.DrawCube(eyePosition + Perp * 0.2f, 0.1f, Color.magenta, 0); + DebugExtensions.DrawCube(eyePosition - Perp * 0.2f, 0.1f, Color.magenta, 0); + + //ears + Vector3 earPosition = DrawPosition + SpawnDirection.ToVector() * 0.2f + Vector3.up * 0.4f; + Vector3 earScale = Quaternion.LookRotation(SpawnDirection.ToVector()) * new Vector3(0.1f, 0.1f, 0.05f); + DebugExtensions.DrawCube(earPosition + Perp * 0.3f, earScale, Color.magenta, 0); + DebugExtensions.DrawCube(earPosition - Perp * 0.3f, earScale, Color.magenta, 0); + + } + + #region Static Functions /// diff --git a/Assets/Scripts/LogicBlocks.meta b/Assets/Scripts/LogicBlocks.meta new file mode 100644 index 0000000..98af9d1 --- /dev/null +++ b/Assets/Scripts/LogicBlocks.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8936b441d7647f74884c94f97bfb8931 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Managers/GameManager.cs b/Assets/Scripts/Managers/GameManager.cs index 7e130ce..c2415b2 100644 --- a/Assets/Scripts/Managers/GameManager.cs +++ b/Assets/Scripts/Managers/GameManager.cs @@ -100,7 +100,7 @@ public class GameManager : MonoBehaviour { if (!player.waiting) { - player.client.Inventory.Remove(player.blockReader.CurrentBlock); + //player.client.Inventory.Remove(player.blockReader.CurrentBlock); player.waiting = player.blockReader.Read(player.character, AnimationTime); } } @@ -146,6 +146,7 @@ public class GameManager : MonoBehaviour Character newChar = Instantiate(characterPrefab); Block startingBlock = SpawnBlocks[(spawnIndex++ % ClientList.ConnectedClients.Count)]; newChar.Initialise(startingBlock, client.Inventory, client.characterAnimal); + newChar.transform.forward = startingBlock.SpawnDirection.ToVector(); playerData.Add(client.ID, new PlayerData(newChar,client)); } }