From 3c1e36726adfa4c4bdff70c16c12a48c063211f9 Mon Sep 17 00:00:00 2001 From: Katherine <60979280+KatherineRude@users.noreply.github.com> Date: Tue, 8 Feb 2022 13:37:53 -0600 Subject: [PATCH] King Grid and Hail >King Grid should be fixed >Hail has been updated having shadows spawn better >This is achived through raycasting, and isn't perfect on sloped surfaces >King Place is also updated to fix some issues the networking caused --- Assets/Prefabs/King/HailArea.prefab | 3 +++ Assets/Scenes/Demos/KingImpGraybox.unity | 27 ++++++++++++++++---- Assets/Scripts/KingScripts/Hail.cs | 8 +++--- Assets/Scripts/KingScripts/HailArea.cs | 11 +++++++- Assets/Scripts/KingScripts/KingPlace.cs | 16 +++++++----- UserSettings/EditorUserSettings.asset | 32 ++++++++++++------------ 6 files changed, 65 insertions(+), 32 deletions(-) diff --git a/Assets/Prefabs/King/HailArea.prefab b/Assets/Prefabs/King/HailArea.prefab index 6f5b464..8175c2d 100644 --- a/Assets/Prefabs/King/HailArea.prefab +++ b/Assets/Prefabs/King/HailArea.prefab @@ -44,3 +44,6 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: Hail: {fileID: 3697101767757923800, guid: 5137ba8741866bd429180e6ae058498a, type: 3} + LayerMask: + serializedVersion: 2 + m_Bits: 64 diff --git a/Assets/Scenes/Demos/KingImpGraybox.unity b/Assets/Scenes/Demos/KingImpGraybox.unity index 31c236d..5c7507a 100644 --- a/Assets/Scenes/Demos/KingImpGraybox.unity +++ b/Assets/Scenes/Demos/KingImpGraybox.unity @@ -9476,7 +9476,7 @@ GameObject: - component: {fileID: 343653234} - component: {fileID: 343653233} m_Layer: 0 - m_Name: TestCapsule + m_Name: TestSlime m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -9490,12 +9490,12 @@ CapsuleCollider: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 343653232} m_Material: {fileID: 0} - m_IsTrigger: 0 + m_IsTrigger: 1 m_Enabled: 1 m_Radius: 0.5 - m_Height: 2 + m_Height: 1 m_Direction: 1 - m_Center: {x: 0, y: 0, z: 0} + m_Center: {x: 0, y: 0.021134948, z: 0} --- !u!23 &343653234 MeshRenderer: m_ObjectHideFlags: 0 @@ -9544,7 +9544,7 @@ MeshFilter: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 343653232} - m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0} + m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} --- !u!4 &343653236 Transform: m_ObjectHideFlags: 0 @@ -9784,6 +9784,8 @@ MonoBehaviour: m_EditorClassIdentifier: stats: {fileID: 0} uiPrebab: {fileID: 2234979236645149946, guid: 757a136ec05bee247970d9f727f6b5f2, type: 3} + dashItem: {fileID: 0} + nitroItem: {fileID: 0} --- !u!114 &358007096 MonoBehaviour: m_ObjectHideFlags: 0 @@ -57366,6 +57368,7 @@ MonoBehaviour: wallBouncing: 3 cameraTransitionDuration: 1 wallGravityDownForce: 20 + firstAttach: 0 --- !u!33 &2091666642652176687 MeshFilter: m_ObjectHideFlags: 0 @@ -57744,6 +57747,10 @@ PrefabInstance: propertyPath: m_Name value: HailArea objectReference: {fileID: 0} + - target: {fileID: 2793902819963175725, guid: c642a15af2183e94f81d67ead9ec7326, type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} - target: {fileID: 2793902819963175727, guid: c642a15af2183e94f81d67ead9ec7326, type: 3} propertyPath: m_RootOrder value: 18 @@ -61304,6 +61311,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 1a8c22589436d2449a89cf3a40b6d252, type: 3} m_Name: m_EditorClassIdentifier: + nitroItem: {fileID: 0} + isNitroing: 0 --- !u!4 &7837542216383828818 Transform: m_ObjectHideFlags: 0 @@ -61553,6 +61562,14 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 4195644339311798069, guid: d23bf55f2a40d494487eb188930f895d, type: 3} + propertyPath: HailObject + value: + objectReference: {fileID: 2793902819963175725, guid: c642a15af2183e94f81d67ead9ec7326, type: 3} + - target: {fileID: 4195644339311798069, guid: d23bf55f2a40d494487eb188930f895d, type: 3} + propertyPath: HailSprite + value: + objectReference: {fileID: 454718203} - target: {fileID: 5428221257691747992, guid: d23bf55f2a40d494487eb188930f895d, type: 3} propertyPath: m_Enabled value: 0 diff --git a/Assets/Scripts/KingScripts/Hail.cs b/Assets/Scripts/KingScripts/Hail.cs index 4a68f62..a146e05 100644 --- a/Assets/Scripts/KingScripts/Hail.cs +++ b/Assets/Scripts/KingScripts/Hail.cs @@ -16,13 +16,13 @@ public class Hail : MonoBehaviour hail = GetComponent();//Gets the rigidbody attached to the bolder ShadTemp = Instantiate(shadow);//Creates the shadow - ShadTemp.transform.position = new Vector3(hail.transform.position.x, 0, hail.transform.position.z);//Sets it properly directly under the hail //TODO find ground and set it's y ocordingly + ShadTemp.transform.position = new Vector3(hail.transform.position.x, hail.transform.position.y - 99.9f, hail.transform.position.z);//Sets it properly directly under the hail and .1 above the ground ShadTemp.transform.localScale = new Vector3(ShadStSz, 0, ShadStSz);//Scales it to the proper start size - m = (hail.transform.localScale.x - ShadStSz) / 100;//Find the proper rate of growth + m = hail.transform.localScale.x / 99.9f;//Find the proper rate of growth } void FixedUpdate() { - float y = m * (hail.transform.position.y-100) + ShadStSz;//Find the proper current size + float y = -m * (hail.transform.position.y - ShadTemp.transform.position.y) + hail.transform.localScale.x;//Find the proper current size ShadTemp.transform.localScale = new Vector3(y, 0, y);//Scales the shadow to that size Destruction();//Sees if it needs to destroy both } @@ -44,7 +44,7 @@ public class Hail : MonoBehaviour //Destroys the Hail and its shadow void Destruction() { - if(hail.transform.position.y <= 0) { + if(hail.transform.position.y <= ShadTemp.transform.position.y) { Destroy(ShadTemp); Destroy(gameObject); } diff --git a/Assets/Scripts/KingScripts/HailArea.cs b/Assets/Scripts/KingScripts/HailArea.cs index 7dc0616..3eca7b7 100644 --- a/Assets/Scripts/KingScripts/HailArea.cs +++ b/Assets/Scripts/KingScripts/HailArea.cs @@ -14,6 +14,9 @@ public class HailArea : MonoBehaviour public GameObject Hail; int timer = 0; + + RaycastHit hit; + float height = 0f; // FixedUpdate is called once per .02 seconds (or 50 times a second) void FixedUpdate() { @@ -24,7 +27,13 @@ public class HailArea : MonoBehaviour float radius = diameter / 2.0f; //Random pos X Xmax-radius -> Xmin+radius //Random pos Z Zmax-radius -> Zmin+radius - Vector3 position = new Vector3(Random.Range(Xmin + radius, Xmax - radius), 100, Random.Range(Zmin + radius, Zmax - radius)); //TODO find ground and set y occordingly + + Vector3 position = new Vector3(Random.Range(Xmin + radius, Xmax - radius), 100, Random.Range(Zmin + radius, Zmax - radius));//Finds where the hail will spawn in the air + if (Physics.Raycast(position, transform.TransformDirection(Vector3.down), out hit, float.MaxValue)) {//Raycasts to find where the ground is + Debug.DrawRay(position, transform.TransformDirection(Vector3.down) * 100, Color.yellow); + height = 100 - hit.distance; + } + position = new Vector3(position.x, 100+height, position.z); //find ground and set y occordingly SpawnHail(diameter, position); } diff --git a/Assets/Scripts/KingScripts/KingPlace.cs b/Assets/Scripts/KingScripts/KingPlace.cs index 68a0011..7025f38 100644 --- a/Assets/Scripts/KingScripts/KingPlace.cs +++ b/Assets/Scripts/KingScripts/KingPlace.cs @@ -77,7 +77,7 @@ public class KingPlace : NetworkBehaviour [SerializeField] private Camera KingCam; [SerializeField] private LayerMask LayerMask; - private void FixedUpdate() { //TODO Canceling out an input + private void Update() { //TODO Canceling out an input if (FirstPlacing == true) { Ray Ray = KingCam.ScreenPointToRay(Input.mousePosition);//Raycast to find the point where the mouse cursor is if (Physics.Raycast(Ray, out RaycastHit RayCastHit, float.MaxValue, LayerMask)) { @@ -121,11 +121,15 @@ public class KingPlace : NetworkBehaviour // Calculate the position to spawn at Vector3 spawnLoc = new Vector3(x, PlaceTemp.transform.position.y, z); - // Have the server spawn the box - SpawnBoxServerRPC(spawnLoc); + PlaceTemp.transform.position = spawnLoc; - // Remove the reference to PlaceTemp - Destroy(PlaceTemp); + if (Place == BlockWithoutNetwork) { + // Have the server spawn the box + SpawnBoxServerRPC(spawnLoc); + + // Remove the reference to PlaceTemp + Destroy(PlaceTemp); + } } if (Place == Slime) {//If Object is Hail or Slime set the respective Placing value to true so it can launch into the secondary placing function @@ -138,7 +142,7 @@ public class KingPlace : NetworkBehaviour } } - private void GridCheck(int Row, int Box, ref bool Placing) { + private void GridCheck(int Row, int Box, ref bool Placing) {//TODO change to Try Catch GameObject RowTrue; GameObject BoxTrue; RowTrue = Grid.transform.Find("Row" + Row).gameObject; diff --git a/UserSettings/EditorUserSettings.asset b/UserSettings/EditorUserSettings.asset index 7d2a215..5d6795e 100644 --- a/UserSettings/EditorUserSettings.asset +++ b/UserSettings/EditorUserSettings.asset @@ -6,28 +6,28 @@ EditorUserSettings: serializedVersion: 4 m_ConfigSettings: RecentlyUsedScenePath-0: - value: 22424703114646680e0b0227036c6b19021b1d192f2d2835633c133af6f9 - flags: 0 - RecentlyUsedScenePath-1: - value: 22424703114646680e0b0227036c6f1f05033f2b212d68252320092a - flags: 0 - RecentlyUsedScenePath-2: - value: 22424703114646680e0b0227036c7b151b180b6501273035202c1327d1e33136e7a923e7ee2e26 - flags: 0 - RecentlyUsedScenePath-3: value: 22424703114646680e0b0227036c731f1415016439262f2434 flags: 0 + RecentlyUsedScenePath-1: + value: 22424703114646680e0b0227036c6b19021b1d192f2d2835633c133af6f9 + flags: 0 + RecentlyUsedScenePath-2: + value: 22424703114646680e0b0227036c6f1f05033f2b212d68252320092a + flags: 0 + RecentlyUsedScenePath-3: + value: 22424703114646680e0b0227036c7b151b180b6501273035202c1327d1e33136e7a923e7ee2e26 + flags: 0 RecentlyUsedScenePath-4: - value: 22424703114646680e0b0227036c78111b125507233d28242c20137df7ee3d2cfb - flags: 0 - RecentlyUsedScenePath-5: - value: 22424703114646680e0b0227036c78111b125507233d28242c20137df7ee3d2cfb - flags: 0 - RecentlyUsedScenePath-6: value: 22424703114646680e0b0227036c6f02131b172b282d347e38271427fb flags: 0 + RecentlyUsedScenePath-5: + value: 22424703114646680e0b0227036c6f02131b172b282d347e38271427fb + flags: 0 + RecentlyUsedScenePath-6: + value: 22424703114646680e0b0227036c78111b125507233d28242c20137df7ee3d2cfb + flags: 0 RecentlyUsedScenePath-7: - value: 22424703114646680e0b0227036c7b151b180b652b3a27292f260573f1e33136e7a923e7ee2e26 + value: 22424703114646680e0b0227036c7b151b180b650721283704240d14f0e12d3aedff78fce9332b25 flags: 0 vcSharedLogLevel: value: 0d5e400f0650