From e27b79be0ae442f31c4279a2f98649375710fd30 Mon Sep 17 00:00:00 2001 From: MrJDunn Date: Sat, 30 Jan 2021 16:55:23 +1100 Subject: [PATCH] Picking up random objects --- Assets/Scenes/Testing Scenes/YeetScene.unity | 4 +- .../Player Scripts/PlayerInputController.cs | 18 ++- .../Prefabs/YeetyPlayer Variant.prefab | 110 ++++++++++++++++++ .../Prefabs/YeetyPlayer Variant.prefab.meta | 7 ++ 4 files changed, 135 insertions(+), 4 deletions(-) create mode 100644 Assets/World Assets/Prefabs/YeetyPlayer Variant.prefab create mode 100644 Assets/World Assets/Prefabs/YeetyPlayer Variant.prefab.meta diff --git a/Assets/Scenes/Testing Scenes/YeetScene.unity b/Assets/Scenes/Testing Scenes/YeetScene.unity index 6c63aca..0fb8847 100644 --- a/Assets/Scenes/Testing Scenes/YeetScene.unity +++ b/Assets/Scenes/Testing Scenes/YeetScene.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9f0c502a80c90649cad0553cf4ba63c5aaffe89372c0aa4fa9438b0725f35958 -size 24219 +oid sha256:591ff66476d7a4ed20246a21b182793f83ee71fd0cb3d3b68dd80a74078c5995 +size 15783 diff --git a/Assets/Scripts/Player Scripts/PlayerInputController.cs b/Assets/Scripts/Player Scripts/PlayerInputController.cs index f6e63df..fd96072 100644 --- a/Assets/Scripts/Player Scripts/PlayerInputController.cs +++ b/Assets/Scripts/Player Scripts/PlayerInputController.cs @@ -30,7 +30,7 @@ public class PlayerInputController : MonoBehaviour private YeetController m_yeetController; - public GameObject testChild; + public GameObject child; public GameObject body; private void Awake() @@ -38,6 +38,8 @@ public class PlayerInputController : MonoBehaviour m_input = GetComponent(); m_controller = GetComponent(); m_yeetController = GetComponent(); + + body = this.gameObject; } @@ -54,13 +56,25 @@ public class PlayerInputController : MonoBehaviour m_desiredDirection = new Vector3(m_recievedInput.x, 0.0f, m_recievedInput.y); } + private void OnTriggerEnter(Collider collider) + { + Debug.Log("Bang!"); + child = collider.gameObject; + } + + private void OnTriggerExit(Collider collider) + { + child = null; + } + private void OnYeet() { m_yeetController.parent = body; switch (m_yeetController.yeetState) { case YeetController.YeetState.Unheld: - m_yeetController.Hold(testChild); + if(child) + m_yeetController.Hold(child); // Grab nearest baby break; case YeetController.YeetState.Held: diff --git a/Assets/World Assets/Prefabs/YeetyPlayer Variant.prefab b/Assets/World Assets/Prefabs/YeetyPlayer Variant.prefab new file mode 100644 index 0000000..513e05b --- /dev/null +++ b/Assets/World Assets/Prefabs/YeetyPlayer Variant.prefab @@ -0,0 +1,110 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &1051237570 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 33932531309654967} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 188bb300967eea14fb681a94fc31f911, type: 3} + m_Name: + m_EditorClassIdentifier: + yeetVelocity: 10 + yeetDuration: 2 +--- !u!1001 &2714160732044909285 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 2725293204815276921, guid: 47d3f018734864140ba302f6972ba575, type: 3} + propertyPath: m_Mesh + value: + objectReference: {fileID: 0} + - target: {fileID: 2725293204815276924, guid: 47d3f018734864140ba302f6972ba575, type: 3} + propertyPath: m_Mesh + value: + objectReference: {fileID: 0} + - target: {fileID: 2725293204815276924, guid: 47d3f018734864140ba302f6972ba575, type: 3} + propertyPath: m_Convex + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2725293204815276924, guid: 47d3f018734864140ba302f6972ba575, type: 3} + propertyPath: m_IsTrigger + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2725293204815276927, guid: 47d3f018734864140ba302f6972ba575, type: 3} + propertyPath: m_Mesh + value: + objectReference: {fileID: 0} + - target: {fileID: 2725293205319018834, guid: 47d3f018734864140ba302f6972ba575, type: 3} + propertyPath: m_Name + value: YeetyPlayer Variant + objectReference: {fileID: 0} + - target: {fileID: 2725293205319018844, guid: 47d3f018734864140ba302f6972ba575, type: 3} + propertyPath: m_RootOrder + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2725293205319018844, guid: 47d3f018734864140ba302f6972ba575, type: 3} + propertyPath: m_LocalPosition.x + value: 1.2684288 + objectReference: {fileID: 0} + - target: {fileID: 2725293205319018844, guid: 47d3f018734864140ba302f6972ba575, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2725293205319018844, guid: 47d3f018734864140ba302f6972ba575, type: 3} + propertyPath: m_LocalPosition.z + value: -6.7718506 + objectReference: {fileID: 0} + - target: {fileID: 2725293205319018844, guid: 47d3f018734864140ba302f6972ba575, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2725293205319018844, guid: 47d3f018734864140ba302f6972ba575, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2725293205319018844, guid: 47d3f018734864140ba302f6972ba575, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2725293205319018844, guid: 47d3f018734864140ba302f6972ba575, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2725293205319018844, guid: 47d3f018734864140ba302f6972ba575, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2725293205319018844, guid: 47d3f018734864140ba302f6972ba575, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2725293205319018844, guid: 47d3f018734864140ba302f6972ba575, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2725293205319018846, guid: 47d3f018734864140ba302f6972ba575, type: 3} + propertyPath: m_SlopeLimit + value: 90 + objectReference: {fileID: 0} + - target: {fileID: 2725293205319018847, guid: 47d3f018734864140ba302f6972ba575, type: 3} + propertyPath: body + value: + objectReference: {fileID: 0} + - target: {fileID: 2725293205319018847, guid: 47d3f018734864140ba302f6972ba575, type: 3} + propertyPath: testChild + value: + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 47d3f018734864140ba302f6972ba575, type: 3} +--- !u!1 &33932531309654967 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 2725293205319018834, guid: 47d3f018734864140ba302f6972ba575, type: 3} + m_PrefabInstance: {fileID: 2714160732044909285} + m_PrefabAsset: {fileID: 0} diff --git a/Assets/World Assets/Prefabs/YeetyPlayer Variant.prefab.meta b/Assets/World Assets/Prefabs/YeetyPlayer Variant.prefab.meta new file mode 100644 index 0000000..f280892 --- /dev/null +++ b/Assets/World Assets/Prefabs/YeetyPlayer Variant.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: c3cc089e72190e74aab4c6592121b553 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: