Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e43949591 | ||
|
|
b09362917a |
@@ -55,7 +55,6 @@
|
|||||||
<UnityVersion>6000.3.6f1</UnityVersion>
|
<UnityVersion>6000.3.6f1</UnityVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Analyzer Include="C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\Extensions\Microsoft\Visual Studio Tools for Unity\Analyzers\Microsoft.Unity.Analyzers.dll" />
|
|
||||||
<Analyzer Include="C:\Program Files\Unity\Hub\Editor\6000.3.6f1\Editor\Data\Tools\BuildPipeline\Unity.SourceGenerators\Unity.SourceGenerators.dll" />
|
<Analyzer Include="C:\Program Files\Unity\Hub\Editor\6000.3.6f1\Editor\Data\Tools\BuildPipeline\Unity.SourceGenerators\Unity.SourceGenerators.dll" />
|
||||||
<Analyzer Include="C:\Program Files\Unity\Hub\Editor\6000.3.6f1\Editor\Data\Tools\BuildPipeline\Unity.SourceGenerators\Unity.Properties.SourceGenerator.dll" />
|
<Analyzer Include="C:\Program Files\Unity\Hub\Editor\6000.3.6f1\Editor\Data\Tools\BuildPipeline\Unity.SourceGenerators\Unity.Properties.SourceGenerator.dll" />
|
||||||
<Analyzer Include="C:\Program Files\Unity\Hub\Editor\6000.3.6f1\Editor\Data\Tools\BuildPipeline\Unity.SourceGenerators\Unity.UIToolkit.SourceGenerator.dll" />
|
<Analyzer Include="C:\Program Files\Unity\Hub\Editor\6000.3.6f1\Editor\Data\Tools\BuildPipeline\Unity.SourceGenerators\Unity.UIToolkit.SourceGenerator.dll" />
|
||||||
|
|||||||
+116
-162
@@ -1690,6 +1690,120 @@ Transform:
|
|||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &1063739947
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1063739950}
|
||||||
|
- component: {fileID: 1063739949}
|
||||||
|
- component: {fileID: 1063739948}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: P_Run01
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!95 &1063739948
|
||||||
|
Animator:
|
||||||
|
serializedVersion: 7
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1063739947}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_Avatar: {fileID: 0}
|
||||||
|
m_Controller: {fileID: 9100000, guid: 86632cb6b3835a44e87fb6f039478d61, type: 2}
|
||||||
|
m_CullingMode: 0
|
||||||
|
m_UpdateMode: 0
|
||||||
|
m_ApplyRootMotion: 0
|
||||||
|
m_LinearVelocityBlending: 0
|
||||||
|
m_StabilizeFeet: 0
|
||||||
|
m_AnimatePhysics: 0
|
||||||
|
m_WarningMessage:
|
||||||
|
m_HasTransformHierarchy: 1
|
||||||
|
m_AllowConstantClipSamplingOptimization: 1
|
||||||
|
m_KeepAnimatorStateOnDisable: 0
|
||||||
|
m_WriteDefaultValuesOnDisable: 0
|
||||||
|
--- !u!212 &1063739949
|
||||||
|
SpriteRenderer:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1063739947}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_CastShadows: 0
|
||||||
|
m_ReceiveShadows: 0
|
||||||
|
m_DynamicOccludee: 1
|
||||||
|
m_StaticShadowCaster: 0
|
||||||
|
m_MotionVectors: 1
|
||||||
|
m_LightProbeUsage: 1
|
||||||
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 0
|
||||||
|
m_RayTraceProcedural: 0
|
||||||
|
m_RayTracingAccelStructBuildFlagsOverride: 0
|
||||||
|
m_RayTracingAccelStructBuildFlags: 1
|
||||||
|
m_SmallMeshCulling: 1
|
||||||
|
m_ForceMeshLod: -1
|
||||||
|
m_MeshLodSelectionBias: 0
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_RendererPriority: 0
|
||||||
|
m_Materials:
|
||||||
|
- {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2}
|
||||||
|
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_GlobalIlluminationMeshLod: 0
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingLayer: 0
|
||||||
|
m_SortingOrder: 0
|
||||||
|
m_MaskInteraction: 0
|
||||||
|
m_Sprite: {fileID: 21300000, guid: c28a83d936216af40976803e59feffac, 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.87, y: 3.58}
|
||||||
|
m_AdaptiveModeThreshold: 0.5
|
||||||
|
m_SpriteTileMode: 0
|
||||||
|
m_WasSpriteAssigned: 1
|
||||||
|
m_SpriteSortPoint: 0
|
||||||
|
--- !u!4 &1063739950
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1063739947}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 8.13, y: 2.32, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &908853548
|
--- !u!1 &908853548
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -2080,58 +2194,6 @@ PrefabInstance:
|
|||||||
m_AddedGameObjects: []
|
m_AddedGameObjects: []
|
||||||
m_AddedComponents: []
|
m_AddedComponents: []
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: 99cce68fc82caea44b5a140697be00a8, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: 99cce68fc82caea44b5a140697be00a8, type: 3}
|
||||||
--- !u!1 &1466477811
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 1466477813}
|
|
||||||
- component: {fileID: 1466477812}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: Treat Spawner TL
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!114 &1466477812
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1466477811}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 14b0bf07aa1abc44a8ebd00cecacd6f4, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::Spawner
|
|
||||||
objectToSpawn: {fileID: 262983251238298495, guid: 80c527a86ad6fc34dbc73ee80c1f2951, type: 3}
|
|
||||||
spawnInterval: 5
|
|
||||||
maxAlive: 0
|
|
||||||
spawnOnStart: 1
|
|
||||||
repeatSpawns: 1
|
|
||||||
launchForce: 0
|
|
||||||
launchRandomAngle: 0
|
|
||||||
spinSpeed: 0
|
|
||||||
--- !u!4 &1466477813
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1466477811}
|
|
||||||
serializedVersion: 2
|
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
||||||
m_LocalPosition: {x: -2.42, y: 2.93, z: 0}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_ConstrainProportionsScale: 0
|
|
||||||
m_Children: []
|
|
||||||
m_Father: {fileID: 0}
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!1 &1654086541
|
--- !u!1 &1654086541
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -2383,110 +2445,6 @@ PrefabInstance:
|
|||||||
m_AddedGameObjects: []
|
m_AddedGameObjects: []
|
||||||
m_AddedComponents: []
|
m_AddedComponents: []
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: 414ae949bae840c4589b38dd91c715e0, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: 414ae949bae840c4589b38dd91c715e0, type: 3}
|
||||||
--- !u!1 &1759124602
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 1759124604}
|
|
||||||
- component: {fileID: 1759124603}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: Treat Spawner TR
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!114 &1759124603
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1759124602}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 14b0bf07aa1abc44a8ebd00cecacd6f4, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::Spawner
|
|
||||||
objectToSpawn: {fileID: 262983251238298495, guid: 80c527a86ad6fc34dbc73ee80c1f2951, type: 3}
|
|
||||||
spawnInterval: 5
|
|
||||||
maxAlive: 0
|
|
||||||
spawnOnStart: 1
|
|
||||||
repeatSpawns: 1
|
|
||||||
launchForce: 0
|
|
||||||
launchRandomAngle: 0
|
|
||||||
spinSpeed: 0
|
|
||||||
--- !u!4 &1759124604
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1759124602}
|
|
||||||
serializedVersion: 2
|
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
||||||
m_LocalPosition: {x: 2.88, y: 2.69, z: 0}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_ConstrainProportionsScale: 0
|
|
||||||
m_Children: []
|
|
||||||
m_Father: {fileID: 0}
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!1 &1830238251
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 1830238253}
|
|
||||||
- component: {fileID: 1830238252}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: Treat Spawner BR
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!114 &1830238252
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1830238251}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 14b0bf07aa1abc44a8ebd00cecacd6f4, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::Spawner
|
|
||||||
objectToSpawn: {fileID: 262983251238298495, guid: 80c527a86ad6fc34dbc73ee80c1f2951, type: 3}
|
|
||||||
spawnInterval: 5
|
|
||||||
maxAlive: 0
|
|
||||||
spawnOnStart: 1
|
|
||||||
repeatSpawns: 1
|
|
||||||
launchForce: 0
|
|
||||||
launchRandomAngle: 0
|
|
||||||
spinSpeed: 0
|
|
||||||
--- !u!4 &1830238253
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1830238251}
|
|
||||||
serializedVersion: 2
|
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
||||||
m_LocalPosition: {x: 4.5, y: -2, z: 0}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_ConstrainProportionsScale: 0
|
|
||||||
m_Children: []
|
|
||||||
m_Father: {fileID: 0}
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!1 &2057686360
|
--- !u!1 &2057686360
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -2922,13 +2880,13 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::Spawner
|
m_EditorClassIdentifier: Assembly-CSharp::Spawner
|
||||||
objectToSpawn: {fileID: 262983251238298495, guid: 80c527a86ad6fc34dbc73ee80c1f2951, type: 3}
|
objectToSpawn: {fileID: 262983251238298495, guid: 80c527a86ad6fc34dbc73ee80c1f2951, type: 3}
|
||||||
spawnInterval: 5
|
spawnInterval: 1.5
|
||||||
maxAlive: 0
|
maxAlive: 0
|
||||||
spawnOnStart: 1
|
spawnOnStart: 1
|
||||||
repeatSpawns: 1
|
repeatSpawns: 1
|
||||||
launchForce: 4
|
launchForce: 4
|
||||||
launchRandomAngle: 360
|
launchRandomAngle: 360
|
||||||
spinSpeed: 180
|
spinSpeed: 100
|
||||||
--- !u!1001 &1760117322204329348
|
--- !u!1001 &1760117322204329348
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -3020,10 +2978,6 @@ SceneRoots:
|
|||||||
- {fileID: 1760117322204329348}
|
- {fileID: 1760117322204329348}
|
||||||
- {fileID: 1277412258}
|
- {fileID: 1277412258}
|
||||||
- {fileID: 1227312797}
|
- {fileID: 1227312797}
|
||||||
- {fileID: 1830238253}
|
|
||||||
- {fileID: 908853550}
|
|
||||||
- {fileID: 1466477813}
|
|
||||||
- {fileID: 1759124604}
|
|
||||||
- {fileID: 792686806}
|
- {fileID: 792686806}
|
||||||
- {fileID: 1685410085}
|
- {fileID: 1685410085}
|
||||||
- {fileID: 377513953}
|
- {fileID: 377513953}
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ public class PlayerPickupController : MonoBehaviour
|
|||||||
public float pickupRange = 2.0f;
|
public float pickupRange = 2.0f;
|
||||||
|
|
||||||
public GameObject heldObject;
|
public GameObject heldObject;
|
||||||
|
private Rigidbody2D heldBody;
|
||||||
|
private float heldBodyMass;
|
||||||
|
private float heldBodyGravity;
|
||||||
|
private RigidbodyType2D heldBodyType;
|
||||||
|
private bool heldBodySimulated;
|
||||||
private PlayerPlatformerController platformerController;
|
private PlayerPlatformerController platformerController;
|
||||||
private PlayerStressController playerStressController;
|
private PlayerStressController playerStressController;
|
||||||
private bool isChargingThrow;
|
private bool isChargingThrow;
|
||||||
@@ -163,9 +168,17 @@ public class PlayerPickupController : MonoBehaviour
|
|||||||
// Disable physics so it doesn't fall or collide with the player
|
// Disable physics so it doesn't fall or collide with the player
|
||||||
if (heldObject.TryGetComponent<Rigidbody2D>(out Rigidbody2D rb))
|
if (heldObject.TryGetComponent<Rigidbody2D>(out Rigidbody2D rb))
|
||||||
{
|
{
|
||||||
|
heldBody = rb;
|
||||||
|
heldBodyMass = rb.mass;
|
||||||
|
heldBodyGravity = rb.gravityScale;
|
||||||
|
heldBodyType = rb.bodyType;
|
||||||
|
heldBodySimulated = rb.simulated;
|
||||||
|
|
||||||
|
rb.simulated = false;
|
||||||
rb.bodyType = RigidbodyType2D.Kinematic;
|
rb.bodyType = RigidbodyType2D.Kinematic;
|
||||||
rb.gravityScale = 0;
|
rb.gravityScale = 0f;
|
||||||
rb.mass = 0;
|
rb.linearVelocity = Vector2.zero;
|
||||||
|
rb.angularVelocity = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trick != null)
|
if (trick != null)
|
||||||
@@ -195,11 +208,14 @@ public class PlayerPickupController : MonoBehaviour
|
|||||||
public void DropObject(bool applyThrow)
|
public void DropObject(bool applyThrow)
|
||||||
{
|
{
|
||||||
// Re-enable physics
|
// Re-enable physics
|
||||||
if (heldObject.TryGetComponent<Rigidbody2D>(out Rigidbody2D rb))
|
if (heldBody != null)
|
||||||
{
|
{
|
||||||
rb.bodyType = RigidbodyType2D.Dynamic;
|
heldBody.simulated = heldBodySimulated;
|
||||||
rb.gravityScale = 1;
|
heldBody.bodyType = heldBodyType;
|
||||||
rb.linearVelocity = Vector2.zero;
|
heldBody.gravityScale = heldBodyGravity;
|
||||||
|
heldBody.mass = heldBodyMass;
|
||||||
|
heldBody.linearVelocity = Vector2.zero;
|
||||||
|
heldBody.angularVelocity = 0f;
|
||||||
}
|
}
|
||||||
if (heldObject.TryGetComponent<TrickController>(out var trick))
|
if (heldObject.TryGetComponent<TrickController>(out var trick))
|
||||||
{
|
{
|
||||||
@@ -217,7 +233,7 @@ public class PlayerPickupController : MonoBehaviour
|
|||||||
heldPickup.enabled = true;
|
heldPickup.enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (applyThrow && heldObject.TryGetComponent<Rigidbody2D>(out Rigidbody2D throwBody))
|
if (applyThrow && heldBody != null)
|
||||||
{
|
{
|
||||||
var direction = 1f;
|
var direction = 1f;
|
||||||
if (platformerController != null && Mathf.Abs(platformerController.LastMoveX) > 0.01f)
|
if (platformerController != null && Mathf.Abs(platformerController.LastMoveX) > 0.01f)
|
||||||
@@ -231,8 +247,9 @@ public class PlayerPickupController : MonoBehaviour
|
|||||||
charge01 = Mathf.Clamp01(heldTime / Mathf.Max(0.01f, throwChargeTime));
|
charge01 = Mathf.Clamp01(heldTime / Mathf.Max(0.01f, throwChargeTime));
|
||||||
}
|
}
|
||||||
var throwSpeed = Mathf.Lerp(minThrowSpeed, maxThrowSpeed, charge01);
|
var throwSpeed = Mathf.Lerp(minThrowSpeed, maxThrowSpeed, charge01);
|
||||||
throwBody.linearVelocity = new Vector2(direction * throwSpeed, 0f);
|
var upwardSpeed = throwUpwardForce * charge01;
|
||||||
throwBody.angularVelocity = 0f;
|
heldBody.linearVelocity = new Vector2(direction * throwSpeed, upwardSpeed);
|
||||||
|
heldBody.angularVelocity = 0f;
|
||||||
}
|
}
|
||||||
heldObject.transform.position += Vector3.up * dropClearance;
|
heldObject.transform.position += Vector3.up * dropClearance;
|
||||||
Collider2D col = heldObject.GetComponent<Collider2D>();
|
Collider2D col = heldObject.GetComponent<Collider2D>();
|
||||||
@@ -241,6 +258,7 @@ public class PlayerPickupController : MonoBehaviour
|
|||||||
// Unparent
|
// Unparent
|
||||||
heldObject.transform.SetParent(null);
|
heldObject.transform.SetParent(null);
|
||||||
heldObject = null;
|
heldObject = null;
|
||||||
|
heldBody = null;
|
||||||
isChargingThrow = false;
|
isChargingThrow = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -275,10 +275,22 @@ public class PlayerPlatformerController : MonoBehaviour
|
|||||||
for (var i = 0; i < hits.Length; i++)
|
for (var i = 0; i < hits.Length; i++)
|
||||||
{
|
{
|
||||||
var hit = hits[i];
|
var hit = hits[i];
|
||||||
if (hit != null && hit != bodyCollider)
|
if (hit == null || hit == bodyCollider || hit.isTrigger)
|
||||||
{
|
{
|
||||||
return true;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hit.GetComponent<PlayerPlatformerController>() != null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hit.GetComponent<TrickController>() != null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -25,14 +25,20 @@ public class TrickController : MonoBehaviour
|
|||||||
[SerializeField] private float wanderWeight = 0.4f;
|
[SerializeField] private float wanderWeight = 0.4f;
|
||||||
[SerializeField] private int maxTricks = 50;
|
[SerializeField] private int maxTricks = 50;
|
||||||
[SerializeField] private float jumpImpulse = 6f;
|
[SerializeField] private float jumpImpulse = 6f;
|
||||||
|
[SerializeField] private float jumpImpulseVariance = 0.25f;
|
||||||
[SerializeField] private float jumpCooldown = 1f;
|
[SerializeField] private float jumpCooldown = 1f;
|
||||||
[SerializeField] private float jumpChancePerSecond = 0.5f;
|
[SerializeField] private float jumpChancePerSecond = 0.5f;
|
||||||
|
[SerializeField] private float jumpArcChance = 0.5f;
|
||||||
|
[SerializeField] private float jumpArcHorizontalImpulse = 2f;
|
||||||
[SerializeField] private LayerMask groundMask = ~0;
|
[SerializeField] private LayerMask groundMask = ~0;
|
||||||
[SerializeField] private float groundCheckDistance = 0.05f;
|
[SerializeField] private float groundCheckDistance = 0.05f;
|
||||||
[SerializeField] private float despawnMinX = -12f;
|
[SerializeField] private float despawnMinX = -12f;
|
||||||
[SerializeField] private float despawnMaxX = 12f;
|
[SerializeField] private float despawnMaxX = 12f;
|
||||||
[SerializeField] private float despawnMinY = -10f;
|
[SerializeField] private float despawnMinY = -10f;
|
||||||
|
[SerializeField] private float despawnMaxY = 20f;
|
||||||
[SerializeField] private float throwControlLockTime = 0.35f;
|
[SerializeField] private float throwControlLockTime = 0.35f;
|
||||||
|
[SerializeField] private float wallCheckDistance = 0.1f;
|
||||||
|
[SerializeField] private float wallAvoidDuration = 0.6f;
|
||||||
|
|
||||||
private Rigidbody2D body;
|
private Rigidbody2D body;
|
||||||
private Transform target;
|
private Transform target;
|
||||||
@@ -44,6 +50,10 @@ public class TrickController : MonoBehaviour
|
|||||||
private float desiredXVelocity;
|
private float desiredXVelocity;
|
||||||
private float nextJumpTime;
|
private float nextJumpTime;
|
||||||
private float movementLockUntil;
|
private float movementLockUntil;
|
||||||
|
private readonly RaycastHit2D[] groundHits = new RaycastHit2D[4];
|
||||||
|
private readonly RaycastHit2D[] wallHits = new RaycastHit2D[4];
|
||||||
|
private float wallAvoidUntil;
|
||||||
|
private float wallAvoidDirection;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
@@ -79,7 +89,7 @@ public class TrickController : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
var position = transform.position;
|
var position = transform.position;
|
||||||
if (position.x < despawnMinX || position.x > despawnMaxX || position.y < despawnMinY)
|
if (position.x < despawnMinX || position.x > despawnMaxX || position.y < despawnMinY || position.y > despawnMaxY)
|
||||||
{
|
{
|
||||||
Destroy(gameObject);
|
Destroy(gameObject);
|
||||||
return;
|
return;
|
||||||
@@ -128,9 +138,6 @@ public class TrickController : MonoBehaviour
|
|||||||
|
|
||||||
if (!IsGrounded())
|
if (!IsGrounded())
|
||||||
{
|
{
|
||||||
var airborne = body.linearVelocity;
|
|
||||||
airborne.x = 0f;
|
|
||||||
body.linearVelocity = airborne;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,6 +163,18 @@ public class TrickController : MonoBehaviour
|
|||||||
desiredX = wanderDirection.x * 0.2f;
|
desiredX = wanderDirection.x * 0.2f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var wallDirection = GetWallAvoidDirection(desiredX);
|
||||||
|
if (wallDirection != 0f)
|
||||||
|
{
|
||||||
|
wallAvoidDirection = wallDirection;
|
||||||
|
wallAvoidUntil = Time.time + wallAvoidDuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Time.time < wallAvoidUntil && Mathf.Abs(wallAvoidDirection) > 0.01f)
|
||||||
|
{
|
||||||
|
desiredX = wallAvoidDirection;
|
||||||
|
}
|
||||||
|
|
||||||
desiredVelocity = new Vector2(Mathf.Clamp(desiredX, -1f, 1f) * moveSpeed, 0f);
|
desiredVelocity = new Vector2(Mathf.Clamp(desiredX, -1f, 1f) * moveSpeed, 0f);
|
||||||
|
|
||||||
var velocity = body.linearVelocity;
|
var velocity = body.linearVelocity;
|
||||||
@@ -311,6 +330,11 @@ public class TrickController : MonoBehaviour
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (body.linearVelocity.y > 0.01f)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var chance = jumpChancePerSecond * Time.fixedDeltaTime;
|
var chance = jumpChancePerSecond * Time.fixedDeltaTime;
|
||||||
if (Random.value > chance)
|
if (Random.value > chance)
|
||||||
{
|
{
|
||||||
@@ -326,7 +350,17 @@ public class TrickController : MonoBehaviour
|
|||||||
}
|
}
|
||||||
velocity.x = jumpDir * moveSpeed;
|
velocity.x = jumpDir * moveSpeed;
|
||||||
body.linearVelocity = velocity;
|
body.linearVelocity = velocity;
|
||||||
body.AddForce(Vector2.up * jumpImpulse, ForceMode2D.Impulse);
|
|
||||||
|
var minImpulse = Mathf.Max(0f, jumpImpulse * (1f - jumpImpulseVariance));
|
||||||
|
var maxImpulse = Mathf.Max(minImpulse, jumpImpulse * (1f + jumpImpulseVariance));
|
||||||
|
var jumpImpulseActual = Random.Range(minImpulse, maxImpulse);
|
||||||
|
body.AddForce(Vector2.up * jumpImpulseActual, ForceMode2D.Impulse);
|
||||||
|
|
||||||
|
if (Random.value < jumpArcChance && jumpArcHorizontalImpulse > 0f)
|
||||||
|
{
|
||||||
|
var arcDir = Random.value < 0.5f ? -1f : 1f;
|
||||||
|
body.AddForce(Vector2.right * arcDir * jumpArcHorizontalImpulse, ForceMode2D.Impulse);
|
||||||
|
}
|
||||||
nextJumpTime = Time.time + jumpCooldown;
|
nextJumpTime = Time.time + jumpCooldown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,22 +372,78 @@ public class TrickController : MonoBehaviour
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var bounds = collider.bounds;
|
var filter = new ContactFilter2D();
|
||||||
var checkSize = new Vector2(bounds.size.x * 0.9f, groundCheckDistance * 2f);
|
filter.SetLayerMask(groundMask);
|
||||||
var checkCenter = new Vector2(bounds.center.x, bounds.min.y - groundCheckDistance);
|
filter.useTriggers = false;
|
||||||
var hits = Physics2D.OverlapBoxAll(checkCenter, checkSize, 0f, groundMask);
|
|
||||||
for (var i = 0; i < hits.Length; i++)
|
var hitCount = collider.Cast(Vector2.down, filter, groundHits, groundCheckDistance);
|
||||||
|
for (var i = 0; i < hitCount; i++)
|
||||||
{
|
{
|
||||||
var hit = hits[i];
|
var hitCollider = groundHits[i].collider;
|
||||||
if (hit != null && hit != collider)
|
if (hitCollider == null || hitCollider == collider)
|
||||||
{
|
{
|
||||||
return true;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hitCollider.GetComponent<TrickController>() != null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hitCollider.GetComponent<PlayerPlatformerController>() != null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private float GetWallAvoidDirection(float desiredX)
|
||||||
|
{
|
||||||
|
if (Mathf.Abs(desiredX) < 0.01f)
|
||||||
|
{
|
||||||
|
return 0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
var collider = GetComponent<Collider2D>();
|
||||||
|
if (collider == null)
|
||||||
|
{
|
||||||
|
return 0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
var filter = new ContactFilter2D();
|
||||||
|
filter.SetLayerMask(groundMask);
|
||||||
|
filter.useTriggers = false;
|
||||||
|
|
||||||
|
var dir = Mathf.Sign(desiredX);
|
||||||
|
var hitCount = collider.Cast(Vector2.right * dir, filter, wallHits, wallCheckDistance);
|
||||||
|
for (var i = 0; i < hitCount; i++)
|
||||||
|
{
|
||||||
|
var hitCollider = wallHits[i].collider;
|
||||||
|
if (hitCollider == null || hitCollider == collider)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hitCollider.GetComponent<TrickController>() != null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hitCollider.GetComponent<PlayerPlatformerController>() != null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void SetCarried(bool carried)
|
public void SetCarried(bool carried)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user