From 147ea366588b892c4c0f72f8245bc7904755367b Mon Sep 17 00:00:00 2001 From: LarsZauberer Date: Sat, 27 Feb 2021 11:34:54 +0100 Subject: [PATCH] Hook Shooting --- Assets/Prefabs/Hook.prefab | 132 +++++++++++ Assets/Prefabs/Hook.prefab.meta | 7 + Assets/Prefabs/Player.prefab | 188 ++++++++++------ Assets/Scenes/SampleScene.unity | 349 +++++++---------------------- Assets/Scripts/Player/Hook.cs | 50 +++++ Assets/Scripts/Player/Hook.cs.meta | 11 + 6 files changed, 402 insertions(+), 335 deletions(-) create mode 100644 Assets/Prefabs/Hook.prefab create mode 100644 Assets/Prefabs/Hook.prefab.meta create mode 100644 Assets/Scripts/Player/Hook.cs create mode 100644 Assets/Scripts/Player/Hook.cs.meta diff --git a/Assets/Prefabs/Hook.prefab b/Assets/Prefabs/Hook.prefab new file mode 100644 index 0000000..f6e4563 --- /dev/null +++ b/Assets/Prefabs/Hook.prefab @@ -0,0 +1,132 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &5763763162042969811 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4993145402615931546} + - component: {fileID: 6167312168718169834} + - component: {fileID: -7018169061865207225} + - component: {fileID: -8534197892154159958} + m_Layer: 0 + m_Name: Hook + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4993145402615931546 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5763763162042969811} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -2.066, y: 1.689, z: -99.00293} + m_LocalScale: {x: 0.5390193, y: 0.5390193, z: 0.5390193} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &6167312168718169834 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5763763162042969811} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, 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: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 21300000, guid: 21fb6714fde0b41b9ba9639d03f5a2a6, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1.632, y: 1.392} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!50 &-7018169061865207225 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5763763162042969811} + m_BodyType: 0 + m_Simulated: 1 + m_UseFullKinematicContacts: 0 + m_UseAutoMass: 0 + m_Mass: 1 + m_LinearDrag: 0 + m_AngularDrag: 0.05 + m_GravityScale: 0 + m_Material: {fileID: 0} + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 +--- !u!61 &-8534197892154159958 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5763763162042969811} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0} + m_SpriteTilingProperty: + border: {x: 0, y: 0, z: 0, w: 0} + pivot: {x: 0.5, y: 0.5} + oldSize: {x: 1.632, y: 1.392} + newSize: {x: 1.632, y: 1.392} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 1.632, y: 1.392} + m_EdgeRadius: 0 diff --git a/Assets/Prefabs/Hook.prefab.meta b/Assets/Prefabs/Hook.prefab.meta new file mode 100644 index 0000000..1c55d34 --- /dev/null +++ b/Assets/Prefabs/Hook.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 4f82f4c1da74fbc4da7731dc62fb2165 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index 9d30769..da764d1 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -1,6 +1,6 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: ---- !u!1 &3660709095795645182 +--- !u!1 &2708059941386668409 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -8,29 +8,29 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 3660709095795645183} + - component: {fileID: 2708059941386668410} m_Layer: 0 - m_Name: Ceiling + m_Name: Floor m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &3660709095795645183 +--- !u!4 &2708059941386668410 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 3660709095795645182} + m_GameObject: {fileID: 2708059941386668409} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0.02, y: 2.218, z: 0} + m_LocalPosition: {x: -0.04, y: -1.9, z: 0} m_LocalScale: {x: 2, y: 2, z: 1} m_Children: [] - m_Father: {fileID: 3660709096162896783} - m_RootOrder: 1 + m_Father: {fileID: 2708059942275157883} + m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &3660709096162896777 +--- !u!1 &2708059942275157885 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -38,42 +38,44 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 3660709096162896783} - - component: {fileID: 3660709096162896782} - - component: {fileID: 3660709096162896781} - - component: {fileID: 3660709096162896780} - - component: {fileID: 3660709096162896779} - - component: {fileID: 3660709096162896778} + - component: {fileID: 2708059942275157883} + - component: {fileID: 2708059942275157882} + - component: {fileID: 2708059942275157880} + - component: {fileID: 2708059942275157887} + - component: {fileID: 2708059942275157886} + - component: {fileID: 2708059942275157636} + - component: {fileID: 2708059942275157881} + - component: {fileID: 2708059942275157637} m_Layer: 0 m_Name: Player - m_TagString: Untagged + m_TagString: Player m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &3660709096162896783 +--- !u!4 &2708059942275157883 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 3660709096162896777} + m_GameObject: {fileID: 2708059942275157885} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -4.1531134, y: -2.0349767, z: 0} + m_LocalPosition: {x: -4.24, y: -0.49, z: 0} m_LocalScale: {x: 0.5, y: 0.5, z: 1} m_Children: - - {fileID: 3660709097050959246} - - {fileID: 3660709095795645183} + - {fileID: 2708059941386668410} + - {fileID: 2708059942646119947} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!212 &3660709096162896782 +--- !u!212 &2708059942275157882 SpriteRenderer: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 3660709096162896777} + m_GameObject: {fileID: 2708059942275157885} m_Enabled: 1 m_CastShadows: 0 m_ReceiveShadows: 0 @@ -117,88 +119,67 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 ---- !u!61 &3660709096162896781 -BoxCollider2D: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 3660709096162896777} - m_Enabled: 1 - m_Density: 1 - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_UsedByEffector: 0 - m_UsedByComposite: 0 - m_Offset: {x: 0, y: 0} - m_SpriteTilingProperty: - border: {x: 0, y: 0, z: 0, w: 0} - pivot: {x: 0.5, y: 0.5} - oldSize: {x: 2.51, y: 3.8} - newSize: {x: 2.51, y: 3.8} - adaptiveTilingThreshold: 0.5 - drawMode: 0 - adaptiveTiling: 0 - m_AutoTiling: 0 - serializedVersion: 2 - m_Size: {x: 2.51, y: 3.8} - m_EdgeRadius: 0 ---- !u!50 &3660709096162896780 +--- !u!50 &2708059942275157880 Rigidbody2D: serializedVersion: 4 m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 3660709096162896777} + m_GameObject: {fileID: 2708059942275157885} m_BodyType: 0 m_Simulated: 1 m_UseFullKinematicContacts: 0 m_UseAutoMass: 0 m_Mass: 1 - m_LinearDrag: 0 - m_AngularDrag: 0.05 - m_GravityScale: 1 - m_Material: {fileID: 0} + m_LinearDrag: 1 + m_AngularDrag: 0 + m_GravityScale: 3 + m_Material: {fileID: 6200000, guid: d0815cf0bda0c6645ba682eebb6e8628, type: 2} m_Interpolate: 0 m_SleepingMode: 1 m_CollisionDetection: 0 m_Constraints: 4 ---- !u!114 &3660709096162896779 +--- !u!114 &2708059942275157887 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 3660709096162896777} + m_GameObject: {fileID: 2708059942275157885} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: e116d093749a8354d939994761c35e10, type: 3} m_Name: m_EditorClassIdentifier: - controller: {fileID: 3660709096162896778} + controller: {fileID: 2708059942275157886} runSpeed: 40 ---- !u!114 &3660709096162896778 + camObj: {fileID: 0} + dead: 0 +--- !u!114 &2708059942275157886 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 3660709096162896777} + m_GameObject: {fileID: 2708059942275157885} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 8dffaca6d717a0b40a7116d8119f8dea, type: 3} m_Name: m_EditorClassIdentifier: - m_JumpForce: 400 + m_JumpForce: 800 m_CrouchSpeed: 0.36 m_MovementSmoothing: 0.05 m_AirControl: 1 - m_WhatIsGround: + groundObstacle: serializedVersion: 2 - m_Bits: 55 - m_GroundCheck: {fileID: 3660709097050959246} - m_CeilingCheck: {fileID: 3660709095795645183} + m_Bits: 0 + groundTarget: + serializedVersion: 2 + m_Bits: 0 + m_GroundCheck: {x: 0, y: 0, z: 0} + m_CeilingCheck: {fileID: 2708059942646119947} m_CrouchDisableCollider: {fileID: 0} OnLandEvent: m_PersistentCalls: @@ -206,7 +187,68 @@ MonoBehaviour: OnCrouchEvent: m_PersistentCalls: m_Calls: [] ---- !u!1 &3660709097050959245 +--- !u!95 &2708059942275157636 +Animator: + serializedVersion: 3 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2708059942275157885} + m_Enabled: 1 + m_Avatar: {fileID: 0} + m_Controller: {fileID: 9100000, guid: 61a0ee060d5f0db4e89aed16d4348c4e, 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 +--- !u!61 &2708059942275157881 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2708059942275157885} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0} + m_SpriteTilingProperty: + border: {x: 0, y: 0, z: 0, w: 0} + pivot: {x: 0.5, y: 0.5} + oldSize: {x: 2.51, y: 3.8} + newSize: {x: 2.51, y: 3.8} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 1.25, y: 2.55} + m_EdgeRadius: 0.3 +--- !u!114 &2708059942275157637 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2708059942275157885} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 165991d1e877cf846b402bdb1032deb0, type: 3} + m_Name: + m_EditorClassIdentifier: + dir: {x: 0, y: 0} + hook: {fileID: 5763763162042969811, guid: 4f82f4c1da74fbc4da7731dc62fb2165, type: 3} + obj: {fileID: 0} + shootingSpeed: 20 +--- !u!1 &2708059942646119946 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -214,25 +256,25 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 3660709097050959246} + - component: {fileID: 2708059942646119947} m_Layer: 0 - m_Name: Floor + m_Name: Ceiling m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &3660709097050959246 +--- !u!4 &2708059942646119947 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 3660709097050959245} + m_GameObject: {fileID: 2708059942646119946} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0.04, y: -2.175, z: 0} + m_LocalPosition: {x: -0.02, y: 1.9, z: 0} m_LocalScale: {x: 2, y: 2, z: 1} m_Children: [] - m_Father: {fileID: 3660709096162896783} - m_RootOrder: 0 + m_Father: {fileID: 2708059942275157883} + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 7432e02..d6286c1 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -121,36 +121,6 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} ---- !u!1 &23671549 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 23671550} - m_Layer: 0 - m_Name: Floor - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &23671550 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 23671549} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0.04, y: -1.9, z: 0} - m_LocalScale: {x: 2, y: 2, z: 1} - m_Children: [] - m_Father: {fileID: 1551824127} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &149813156 GameObject: m_ObjectHideFlags: 3 @@ -962,7 +932,7 @@ Tilemap: - {fileID: 21300000, guid: 8cfdb1cceb6f3474e8588f63865ae102, type: 3} - {fileID: 21300000, guid: eff992e636922ed4e9dfec05617cc378, type: 3} - {fileID: 21300000, guid: 2f67cd62e85a95040b1ed8b66dae0788, type: 3} - m_AnimationSpeed: 10 + m_AnimationSpeed: 10.000001 m_AnimationTimeOffset: 0 m_IsLooping: 1 - first: {x: 17, y: -1, z: 0} @@ -9800,237 +9770,12 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 ---- !u!1 &1247446414 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1247446415} - m_Layer: 0 - m_Name: Ceiling - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1247446415 +--- !u!4 &1551824127 stripped Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1247446414} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0.02, y: 1.9, z: 0} - m_LocalScale: {x: 2, y: 2, z: 1} - m_Children: [] - m_Father: {fileID: 1551824127} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1551824121 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1551824127} - - component: {fileID: 1551824126} - - component: {fileID: 1551824124} - - component: {fileID: 1551824123} - - component: {fileID: 1551824122} - - component: {fileID: 1551824128} - - component: {fileID: 1551824125} - m_Layer: 0 - m_Name: Player - m_TagString: Player - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1551824122 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1551824121} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 8dffaca6d717a0b40a7116d8119f8dea, type: 3} - m_Name: - m_EditorClassIdentifier: - m_JumpForce: 800 - m_CrouchSpeed: 0.36 - m_MovementSmoothing: 0.05 - m_AirControl: 1 - groundObstacle: - serializedVersion: 2 - m_Bits: 0 - groundTarget: - serializedVersion: 2 - m_Bits: 0 - m_GroundCheck: {x: 0, y: 0, z: 0} - m_CeilingCheck: {fileID: 1247446415} - m_CrouchDisableCollider: {fileID: 0} - OnLandEvent: - m_PersistentCalls: - m_Calls: [] - OnCrouchEvent: - m_PersistentCalls: - m_Calls: [] ---- !u!114 &1551824123 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1551824121} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e116d093749a8354d939994761c35e10, type: 3} - m_Name: - m_EditorClassIdentifier: - controller: {fileID: 1551824122} - runSpeed: 40 - camObj: {fileID: 519420028} - dead: 0 ---- !u!50 &1551824124 -Rigidbody2D: - serializedVersion: 4 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1551824121} - m_BodyType: 0 - m_Simulated: 1 - m_UseFullKinematicContacts: 0 - m_UseAutoMass: 0 - m_Mass: 1 - m_LinearDrag: 1 - m_AngularDrag: 0 - m_GravityScale: 3 - m_Material: {fileID: 6200000, guid: d0815cf0bda0c6645ba682eebb6e8628, type: 2} - m_Interpolate: 0 - m_SleepingMode: 1 - m_CollisionDetection: 0 - m_Constraints: 4 ---- !u!61 &1551824125 -BoxCollider2D: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1551824121} - m_Enabled: 1 - m_Density: 1 - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_UsedByEffector: 0 - m_UsedByComposite: 0 - m_Offset: {x: 0, y: 0} - m_SpriteTilingProperty: - border: {x: 0, y: 0, z: 0, w: 0} - pivot: {x: 0.5, y: 0.5} - oldSize: {x: 2.51, y: 3.8} - newSize: {x: 2.51, y: 3.8} - adaptiveTilingThreshold: 0.5 - drawMode: 0 - adaptiveTiling: 0 - m_AutoTiling: 0 - serializedVersion: 2 - m_Size: {x: 1.25, y: 2.55} - m_EdgeRadius: 0.3 ---- !u!212 &1551824126 -SpriteRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1551824121} - m_Enabled: 1 - m_CastShadows: 0 - m_ReceiveShadows: 0 - m_DynamicOccludee: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 10754, 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: 0 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_Sprite: {fileID: 21300000, guid: a0137a8e7f3c1b44fa0ef27e53712f35, type: 3} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_FlipX: 0 - m_FlipY: 0 - m_DrawMode: 0 - m_Size: {x: 2.51, y: 3.8} - m_AdaptiveModeThreshold: 0.5 - m_SpriteTileMode: 0 - m_WasSpriteAssigned: 1 - m_MaskInteraction: 0 - m_SpriteSortPoint: 0 ---- !u!4 &1551824127 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1551824121} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -4.24, y: -0.49, z: 0} - m_LocalScale: {x: 0.5, y: 0.5, z: 1} - m_Children: - - {fileID: 23671550} - - {fileID: 1247446415} - m_Father: {fileID: 0} - m_RootOrder: 3 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!95 &1551824128 -Animator: - serializedVersion: 3 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 2708059942275157883, guid: d83047ec43286764f8c30b46f65db4f0, + type: 3} + m_PrefabInstance: {fileID: 2708059941401820036} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1551824121} - m_Enabled: 1 - m_Avatar: {fileID: 0} - m_Controller: {fileID: 9100000, guid: 61a0ee060d5f0db4e89aed16d4348c4e, 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 --- !u!1 &1586489444 GameObject: m_ObjectHideFlags: 0 @@ -10089,7 +9834,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 7 + m_RootOrder: 8 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &1745399710 PrefabInstance: @@ -10625,6 +10370,86 @@ MonoBehaviour: m_BoundingShape2D: {fileID: 1586489445} m_ConfineScreenEdges: 1 m_Damping: 0 +--- !u!1001 &2708059941401820036 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 2708059942275157637, guid: d83047ec43286764f8c30b46f65db4f0, + type: 3} + propertyPath: hook + value: + objectReference: {fileID: 5763763162042969811, guid: 4f82f4c1da74fbc4da7731dc62fb2165, + type: 3} + - target: {fileID: 2708059942275157883, guid: d83047ec43286764f8c30b46f65db4f0, + type: 3} + propertyPath: m_RootOrder + value: 3 + objectReference: {fileID: 0} + - target: {fileID: 2708059942275157883, guid: d83047ec43286764f8c30b46f65db4f0, + type: 3} + propertyPath: m_LocalPosition.x + value: -4.24 + objectReference: {fileID: 0} + - target: {fileID: 2708059942275157883, guid: d83047ec43286764f8c30b46f65db4f0, + type: 3} + propertyPath: m_LocalPosition.y + value: -0.49 + objectReference: {fileID: 0} + - target: {fileID: 2708059942275157883, guid: d83047ec43286764f8c30b46f65db4f0, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2708059942275157883, guid: d83047ec43286764f8c30b46f65db4f0, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2708059942275157883, guid: d83047ec43286764f8c30b46f65db4f0, + type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2708059942275157883, guid: d83047ec43286764f8c30b46f65db4f0, + type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2708059942275157883, guid: d83047ec43286764f8c30b46f65db4f0, + type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2708059942275157883, guid: d83047ec43286764f8c30b46f65db4f0, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2708059942275157883, guid: d83047ec43286764f8c30b46f65db4f0, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2708059942275157883, guid: d83047ec43286764f8c30b46f65db4f0, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2708059942275157885, guid: d83047ec43286764f8c30b46f65db4f0, + type: 3} + propertyPath: m_Name + value: Player + objectReference: {fileID: 0} + - target: {fileID: 2708059942275157887, guid: d83047ec43286764f8c30b46f65db4f0, + type: 3} + propertyPath: camObj + value: + objectReference: {fileID: 519420028} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: d83047ec43286764f8c30b46f65db4f0, type: 3} --- !u!1001 &3427948639706760606 PrefabInstance: m_ObjectHideFlags: 0 @@ -10675,7 +10500,7 @@ PrefabInstance: - target: {fileID: 3427948640443327689, guid: 0a7d3fa94abdbc342bd6e88b4643c36e, type: 3} propertyPath: m_RootOrder - value: 8 + value: 7 objectReference: {fileID: 0} - target: {fileID: 3427948640443327689, guid: 0a7d3fa94abdbc342bd6e88b4643c36e, type: 3} diff --git a/Assets/Scripts/Player/Hook.cs b/Assets/Scripts/Player/Hook.cs new file mode 100644 index 0000000..185cad6 --- /dev/null +++ b/Assets/Scripts/Player/Hook.cs @@ -0,0 +1,50 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Hook : MonoBehaviour +{ + private Vector3 mousePoint; + public Vector2 dir; + public GameObject hook; + public GameObject obj; + public float shootingSpeed = 10f; + // Start is called before the first frame update + void Start() + { + Update(); + } + + // Update is called once per frame + void Update() + { + if (Input.GetButtonDown("Fire1")) { + Shoot(); + } + } + + private void FixedUpdate() { + if (obj) { + Rigidbody2D r = obj.GetComponent(); + // r.isKinematic = false; + r.AddForce(CalculateDirection(mousePoint, transform.position)*Time.fixedDeltaTime*shootingSpeed, ForceMode2D.Impulse); + // r.AddForce(GravityVector, ForceMode2D.Impulse); + } + } + + public void Shoot() { + mousePoint = Camera.main.ScreenToWorldPoint(Input.mousePosition); + obj = Instantiate(hook) as GameObject; + obj.transform.position = transform.position; + } + + public Vector2 CalculateDirection(Vector3 mouse, Vector3 player) { + Vector2 vec = new Vector2(); + vec.x = mouse.x-player.x; + vec.y = mouse.y-player.y; + + vec = vec/vec.magnitude; + + return vec; + } +} diff --git a/Assets/Scripts/Player/Hook.cs.meta b/Assets/Scripts/Player/Hook.cs.meta new file mode 100644 index 0000000..4bba474 --- /dev/null +++ b/Assets/Scripts/Player/Hook.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 165991d1e877cf846b402bdb1032deb0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: