From 6fe14abe625939d549dcbc0b41ec96a264143443 Mon Sep 17 00:00:00 2001 From: Katherine <60979280+KatherineRude@users.noreply.github.com> Date: Fri, 10 Dec 2021 21:46:42 -0600 Subject: [PATCH] King placement prototype >King can place objects on the race track >It is based on their cursor location in 3D space >Objects need to be switched for their proper abilities >Objects need to snap to Grid --- .../Prefabs/Block2Inch_Wood_Large.prefab | 2 +- Assets/Scenes/Demos/KingImpGraybox.unity | 25 +++++++++++-------- Assets/Scripts/KingScripts/KingPlace.cs | 13 +++++----- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/Assets/Art Assets/ToyBlocks/Prefabs/Block2Inch_Wood_Large.prefab b/Assets/Art Assets/ToyBlocks/Prefabs/Block2Inch_Wood_Large.prefab index c364f20..e1b1d15 100644 --- a/Assets/Art Assets/ToyBlocks/Prefabs/Block2Inch_Wood_Large.prefab +++ b/Assets/Art Assets/ToyBlocks/Prefabs/Block2Inch_Wood_Large.prefab @@ -28,7 +28,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 8397943440757562192} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalPosition: {x: -273.3493, y: 24.995426, z: 520.2409} m_LocalScale: {x: 40, y: 40, z: 40} m_Children: [] m_Father: {fileID: 0} diff --git a/Assets/Scenes/Demos/KingImpGraybox.unity b/Assets/Scenes/Demos/KingImpGraybox.unity index cced584..dd4dcd8 100644 --- a/Assets/Scenes/Demos/KingImpGraybox.unity +++ b/Assets/Scenes/Demos/KingImpGraybox.unity @@ -157078,7 +157078,7 @@ Transform: m_GameObject: {fileID: 343653232} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 486.3, y: 501.02, z: 1306.41} - m_LocalScale: {x: 3, y: 3, z: 3} + m_LocalScale: {x: 20, y: 20, z: 20} m_Children: [] m_Father: {fileID: 0} m_RootOrder: 19 @@ -177597,7 +177597,7 @@ GameObject: - component: {fileID: 386288446} - component: {fileID: 386288448} - component: {fileID: 386288447} - m_Layer: 0 + m_Layer: 6 m_Name: Foothills 2 m_TagString: Untagged m_Icon: {fileID: 0} @@ -208600,7 +208600,7 @@ Transform: m_GameObject: {fileID: 454718203} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 478.89, y: 504.7, z: 1311.67} - m_LocalScale: {x: 3, y: 3, z: 3} + m_LocalScale: {x: 20, y: 20, z: 20} m_Children: [] m_Father: {fileID: 0} m_RootOrder: 18 @@ -219868,12 +219868,15 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 1b197075b52c7e644a525bf0ff3f69a7, type: 3} m_Name: m_EditorClassIdentifier: - KingCam: {fileID: 554290870} Thunderstorm: {fileID: 0} - Block: {fileID: 809811071} + Block: {fileID: 8397943440757562192, guid: 8a60e3ee825870040bcb23f43e470e25, type: 3} Hail: {fileID: 454718203} Slime: {fileID: 343653232} Grid: {fileID: 1683387139} + KingCam: {fileID: 554290870} + LayerMask: + serializedVersion: 2 + m_Bits: 64 --- !u!114 &480134715 MonoBehaviour: m_ObjectHideFlags: 0 @@ -364185,7 +364188,7 @@ Transform: m_GameObject: {fileID: 809811071} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 492, y: 500, z: 1303.3} - m_LocalScale: {x: 3, y: 3, z: 3} + m_LocalScale: {x: 20, y: 20, z: 20} m_Children: [] m_Father: {fileID: 0} m_RootOrder: 17 @@ -640774,7 +640777,7 @@ GameObject: - component: {fileID: 1428014568} - component: {fileID: 1428014567} - component: {fileID: 1428014566} - m_Layer: 0 + m_Layer: 6 m_Name: Valley m_TagString: Untagged m_Icon: {fileID: 0} @@ -784666,7 +784669,7 @@ GameObject: - component: {fileID: 1750980054} - component: {fileID: 1750980056} - component: {fileID: 1750980055} - m_Layer: 0 + m_Layer: 6 m_Name: Foothills 1 m_TagString: Untagged m_Icon: {fileID: 0} @@ -794255,7 +794258,7 @@ GameObject: - component: {fileID: 1771680911} - component: {fileID: 1771680913} - component: {fileID: 1771680912} - m_Layer: 0 + m_Layer: 6 m_Name: Mountain m_TagString: Untagged m_Icon: {fileID: 0} @@ -867924,7 +867927,7 @@ GameObject: - component: {fileID: 1932658587} - component: {fileID: 1932658589} - component: {fileID: 1932658588} - m_Layer: 0 + m_Layer: 6 m_Name: Plains 2 m_TagString: Untagged m_Icon: {fileID: 0} @@ -890460,7 +890463,7 @@ GameObject: - component: {fileID: 1983875393} - component: {fileID: 1983875395} - component: {fileID: 1983875394} - m_Layer: 0 + m_Layer: 6 m_Name: Plains 1 m_TagString: Untagged m_Icon: {fileID: 0} diff --git a/Assets/Scripts/KingScripts/KingPlace.cs b/Assets/Scripts/KingScripts/KingPlace.cs index 60cc5b0..a72f7c9 100644 --- a/Assets/Scripts/KingScripts/KingPlace.cs +++ b/Assets/Scripts/KingScripts/KingPlace.cs @@ -52,14 +52,8 @@ public class KingPlace : MonoBehaviour { //Layout the grid Grid.GetComponent().GridSwitch(true); - //The player selects where on the grid they want to place the object + //The player can then see where the object will be placed, reletive to the Grid Placing = true; - /* Center anchored - * Should be "simple" to snap the cursor poistion onto the grid. - */ - - //The object is placed there - //Energy is spent } [SerializeField] private Camera KingCam; @@ -71,6 +65,11 @@ public class KingPlace : MonoBehaviour { if (Physics.Raycast(Ray, out RaycastHit RayCastHit, float.MaxValue, LayerMask)) { Place.transform.position = RayCastHit.point; } + if (Input.GetMouseButtonUp(1)) {//Reads the player letting up the right mouse button + Instantiate(Place);//Place the object (Snap it up and to Grid) + Grid.GetComponent().GridSwitch(false); //Switch off the grid + Placing = false;//Stop placing + } } } }