Add recovery scene and Pump/Upper objects with physics configurations
- Introduce `0.unity` recovery scene for testing and backup purposes. - Add `Pump` GameObject with components including Rigidbody, CapsuleCollider, and MeshRenderer for physics interactions. - Add `Upper` GameObject with a Transform component for hierarchical relationships. - Configure physics parameters such as damping, constraints, and Rigidbody properties. - Update object layers, tags, and rendering configurations for improved scene setup.
This commit is contained in:
34
Assets/BottomPump.cs
Normal file
34
Assets/BottomPump.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class BottomPump : MonoBehaviour
|
||||
{
|
||||
public bool Grounded { get; private set; }
|
||||
|
||||
[SerializeField]
|
||||
private LayerMask layerMask;
|
||||
|
||||
public Action<bool> GroundedChanged;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
GroundedChanged?.Invoke(GetGroundedState());
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
var groundedNow = GetGroundedState();
|
||||
|
||||
if (groundedNow == Grounded) return;
|
||||
|
||||
Grounded = groundedNow;
|
||||
GroundedChanged?.Invoke(Grounded);
|
||||
}
|
||||
|
||||
private bool GetGroundedState()
|
||||
{
|
||||
const float distance = .35f;
|
||||
|
||||
return Physics.Raycast(transform.position, -transform.up, distance, layerMask);
|
||||
}
|
||||
}
|
||||
3
Assets/BottomPump.cs.meta
Normal file
3
Assets/BottomPump.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9df908265aaa40a8b908df0363de539c
|
||||
timeCreated: 1761474249
|
||||
@@ -136,6 +136,7 @@ GameObject:
|
||||
- component: {fileID: 109005186}
|
||||
- component: {fileID: 109005185}
|
||||
- component: {fileID: 109005192}
|
||||
- component: {fileID: 109005193}
|
||||
m_Layer: 0
|
||||
m_Name: Pump
|
||||
m_TagString: Untagged
|
||||
@@ -189,7 +190,7 @@ CapsuleCollider:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 109005183}
|
||||
m_Material: {fileID: 13400000, guid: b6f35084eb7ecff4c894342a0fe3b318, type: 2}
|
||||
m_Material: {fileID: 13400000, guid: e992aae4b1ad1f6448b54c4b9f54fd26, type: 2}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
@@ -212,7 +213,7 @@ MeshFilter:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 109005183}
|
||||
m_Mesh: {fileID: 1683927177}
|
||||
m_Mesh: {fileID: 1176145176}
|
||||
--- !u!23 &109005188
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -496,7 +497,7 @@ MonoBehaviour:
|
||||
m_AreaError: 15
|
||||
m_PreserveMeshAssetOnDestroy: 0
|
||||
assetGuid:
|
||||
m_Mesh: {fileID: 1683927177}
|
||||
m_Mesh: {fileID: 1176145176}
|
||||
m_VersionIndex: 14098
|
||||
m_IsSelectable: 1
|
||||
m_SelectedFaces:
|
||||
@@ -540,6 +541,21 @@ CapsuleCollider:
|
||||
m_Height: 0
|
||||
m_Direction: 1
|
||||
m_Center: {x: 0, y: -0.26, z: 0}
|
||||
--- !u!114 &109005193
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 109005183}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 9df908265aaa40a8b908df0363de539c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::BottomPump
|
||||
layerMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 8
|
||||
--- !u!1 &125187157
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -691,7 +707,7 @@ ConfigurableJoint:
|
||||
useAcceleration: 0
|
||||
m_YDrive:
|
||||
serializedVersion: 4
|
||||
positionSpring: 2000
|
||||
positionSpring: 1800
|
||||
positionDamper: 0
|
||||
maximumForce: 3.4028233e+38
|
||||
useAcceleration: 1
|
||||
@@ -741,7 +757,7 @@ Rigidbody:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 125187157}
|
||||
serializedVersion: 5
|
||||
m_Mass: 5
|
||||
m_Mass: 5.5
|
||||
m_LinearDamping: 0
|
||||
m_AngularDamping: 40
|
||||
m_CenterOfMass: {x: 0, y: -0.03, z: 0}
|
||||
@@ -1072,22 +1088,14 @@ MonoBehaviour:
|
||||
jumpingAngularDamping: 250
|
||||
jumpTimerMilliseconds: 450
|
||||
torqueForce: 8
|
||||
dampedTorqueForce: 2
|
||||
lerpSpeed: 7
|
||||
jumpDownForce: 3.5
|
||||
jumpUpForce: 3.5
|
||||
forceMode: 2
|
||||
pump: {fileID: 109005184}
|
||||
rotationForceMode: 2
|
||||
lerp: 1
|
||||
debugUi: {fileID: 375111999}
|
||||
timeScale: 1
|
||||
lerp: 1
|
||||
layerMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 8
|
||||
autoCenterKp: 15
|
||||
autoCenterKd: 2.5
|
||||
autoCenterMaxTorque: 30
|
||||
autoCenterDeadZoneDeg: 0.5
|
||||
bottomPump: {fileID: 109005193}
|
||||
--- !u!1 &127015120
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -3574,6 +3582,184 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 59.95}
|
||||
--- !u!43 &1176145176
|
||||
Mesh:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: pb_Mesh-17466(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
|
||||
serializedVersion: 12
|
||||
m_SubMeshes:
|
||||
- serializedVersion: 2
|
||||
firstByte: 0
|
||||
indexCount: 36
|
||||
topology: 0
|
||||
baseVertex: 0
|
||||
firstVertex: 0
|
||||
vertexCount: 24
|
||||
localAABB:
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
m_Extent: {x: 0.025000006, y: 0.27861288, z: 0.025}
|
||||
m_Shapes:
|
||||
vertices: []
|
||||
shapes: []
|
||||
channels: []
|
||||
fullWeights: []
|
||||
m_BindPose: []
|
||||
m_BoneNameHashes:
|
||||
m_RootBoneNameHash: 0
|
||||
m_BonesAABB: []
|
||||
m_VariableBoneCountWeights:
|
||||
m_Data:
|
||||
m_MeshCompression: 0
|
||||
m_IsReadable: 1
|
||||
m_KeepVertices: 1
|
||||
m_KeepIndices: 1
|
||||
m_IndexFormat: 0
|
||||
m_IndexBuffer: 000001000200010003000200040005000600050007000600080009000a0009000b000a000c000d000e000d000f000e00100011001200110013001200140015001600150017001600
|
||||
m_VertexData:
|
||||
serializedVersion: 3
|
||||
m_VertexCount: 24
|
||||
m_Channels:
|
||||
- stream: 0
|
||||
offset: 0
|
||||
format: 0
|
||||
dimension: 3
|
||||
- stream: 0
|
||||
offset: 12
|
||||
format: 0
|
||||
dimension: 3
|
||||
- stream: 0
|
||||
offset: 24
|
||||
format: 0
|
||||
dimension: 4
|
||||
- stream: 0
|
||||
offset: 0
|
||||
format: 0
|
||||
dimension: 0
|
||||
- stream: 0
|
||||
offset: 40
|
||||
format: 0
|
||||
dimension: 2
|
||||
- stream: 0
|
||||
offset: 0
|
||||
format: 0
|
||||
dimension: 0
|
||||
- stream: 0
|
||||
offset: 0
|
||||
format: 0
|
||||
dimension: 0
|
||||
- stream: 0
|
||||
offset: 0
|
||||
format: 0
|
||||
dimension: 0
|
||||
- stream: 0
|
||||
offset: 0
|
||||
format: 0
|
||||
dimension: 0
|
||||
- stream: 0
|
||||
offset: 0
|
||||
format: 0
|
||||
dimension: 0
|
||||
- stream: 0
|
||||
offset: 0
|
||||
format: 0
|
||||
dimension: 0
|
||||
- stream: 0
|
||||
offset: 0
|
||||
format: 0
|
||||
dimension: 0
|
||||
- stream: 0
|
||||
offset: 0
|
||||
format: 0
|
||||
dimension: 0
|
||||
- stream: 0
|
||||
offset: 0
|
||||
format: 0
|
||||
dimension: 0
|
||||
m_DataSize: 1152
|
||||
_typelessdata: d0ccccbc59a68ebecdcccc3c00000000000000000000803f000080bf0000000000000000000080bfd0cc4c3d4fb3e23ed0cccc3c59a68ebecdcccc3c00000000000000000000803f000080bf0000000000000000000080bf000000004fb3e23ed0ccccbc59a68e3ecdcccc3c00000000000000000000803f000080bf0000000000000000000080bfd0cc4c3d0000803fd0cccc3c59a68e3ecdcccc3c00000000000000000000803f000080bf0000000000000000000080bf000000000000803fd0cccc3c59a68ebecdcccc3c0000803f000000000000000000000000000000000000803f000080bfcdcc4c3d4fb3e23ed0cccc3c59a68ebecdccccbc0000803f000000000000000000000000000000000000803f000080bf000000004fb3e23ed0cccc3c59a68e3ecdcccc3c0000803f000000000000000000000000000000000000803f000080bfcdcc4c3d0000803fd0cccc3c59a68e3ecdccccbc0000803f000000000000000000000000000000000000803f000080bf000000000000803fd0cccc3c59a68ebecdccccbc0000000000000000000080bf0000803f0000000000000000000080bfd0cc4c3d4fb3e23ed0ccccbc59a68ebecdccccbc0000000000000000000080bf0000803f0000000000000000000080bf000000004fb3e23ed0cccc3c59a68e3ecdccccbc0000000000000000000080bf0000803f0000000000000000000080bfd0cc4c3d0000803fd0ccccbc59a68e3ecdccccbc0000000000000000000080bf0000803f0000000000000000000080bf000000000000803fd0ccccbc59a68ebecdccccbc000080bf00000000000000000000000000000000000080bf000080bfcdcc4c3d4fb3e23ed0ccccbc59a68ebecdcccc3c000080bf00000000000000000000000000000000000080bf000080bf000000004fb3e23ed0ccccbc59a68e3ecdccccbc000080bf00000000000000000000000000000000000080bf000080bfcdcc4c3d0000803fd0ccccbc59a68e3ecdcccc3c000080bf00000000000000000000000000000000000080bf000080bf000000000000803fd0ccccbc59a68e3ecdcccc3c000000000000803f000000000000803f0000000000000000000080bf000000000000803fd0cccc3c59a68e3ecdcccc3c000000000000803f000000000000803f0000000000000000000080bfd0cc4c3d0000803fd0ccccbc59a68e3ecdccccbc000000000000803f000000000000803f0000000000000000000080bf000000003433733fd0cccc3c59a68e3ecdccccbc000000000000803f000000000000803f0000000000000000000080bfd0cc4c3d3433733fd0ccccbc59a68ebecdccccbc00000000000080bf00000000000080bf0000000000000000000080bfd0cc4c3d3433733fd0cccc3c59a68ebecdccccbc00000000000080bf00000000000080bf0000000000000000000080bf000000003433733fd0ccccbc59a68ebecdcccc3c00000000000080bf00000000000080bf0000000000000000000080bfd0cc4c3d0000803fd0cccc3c59a68ebecdcccc3c00000000000080bf00000000000080bf0000000000000000000080bf000000000000803f
|
||||
m_CompressedMesh:
|
||||
m_Vertices:
|
||||
m_NumItems: 0
|
||||
m_Range: 0
|
||||
m_Start: 0
|
||||
m_Data:
|
||||
m_BitSize: 0
|
||||
m_UV:
|
||||
m_NumItems: 0
|
||||
m_Range: 0
|
||||
m_Start: 0
|
||||
m_Data:
|
||||
m_BitSize: 0
|
||||
m_Normals:
|
||||
m_NumItems: 0
|
||||
m_Range: 0
|
||||
m_Start: 0
|
||||
m_Data:
|
||||
m_BitSize: 0
|
||||
m_Tangents:
|
||||
m_NumItems: 0
|
||||
m_Range: 0
|
||||
m_Start: 0
|
||||
m_Data:
|
||||
m_BitSize: 0
|
||||
m_Weights:
|
||||
m_NumItems: 0
|
||||
m_Data:
|
||||
m_BitSize: 0
|
||||
m_NormalSigns:
|
||||
m_NumItems: 0
|
||||
m_Data:
|
||||
m_BitSize: 0
|
||||
m_TangentSigns:
|
||||
m_NumItems: 0
|
||||
m_Data:
|
||||
m_BitSize: 0
|
||||
m_FloatColors:
|
||||
m_NumItems: 0
|
||||
m_Range: 0
|
||||
m_Start: 0
|
||||
m_Data:
|
||||
m_BitSize: 0
|
||||
m_BoneIndices:
|
||||
m_NumItems: 0
|
||||
m_Data:
|
||||
m_BitSize: 0
|
||||
m_Triangles:
|
||||
m_NumItems: 0
|
||||
m_Data:
|
||||
m_BitSize: 0
|
||||
m_UVInfo: 0
|
||||
m_LocalAABB:
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
m_Extent: {x: 0.025000006, y: 0.27861288, z: 0.025}
|
||||
m_MeshUsageFlags: 0
|
||||
m_CookingOptions: 30
|
||||
m_BakedConvexCollisionMesh:
|
||||
m_BakedTriangleCollisionMesh:
|
||||
'm_MeshMetrics[0]': 1.000001
|
||||
'm_MeshMetrics[1]': 1
|
||||
m_MeshOptimizationFlags: 1
|
||||
m_StreamData:
|
||||
serializedVersion: 2
|
||||
offset: 0
|
||||
size: 0
|
||||
path:
|
||||
m_MeshLodInfo:
|
||||
serializedVersion: 2
|
||||
m_LodSelectionCurve:
|
||||
serializedVersion: 1
|
||||
m_LodSlope: 0
|
||||
m_LodBias: 0
|
||||
m_NumLevels: 1
|
||||
m_SubMeshes:
|
||||
- serializedVersion: 2
|
||||
m_Levels:
|
||||
- serializedVersion: 1
|
||||
m_IndexStart: 0
|
||||
m_IndexCount: 0
|
||||
--- !u!43 &1316371527
|
||||
Mesh:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -3857,8 +4043,8 @@ Transform:
|
||||
m_GameObject: {fileID: 1363790841}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -2.381, y: 2.36, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_LocalPosition: {x: -2.381, y: 2.981, z: 0}
|
||||
m_LocalScale: {x: 1, y: 0.12, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
@@ -3875,6 +4061,7 @@ GameObject:
|
||||
- component: {fileID: 1474109342}
|
||||
- component: {fileID: 1474109341}
|
||||
- component: {fileID: 1474109340}
|
||||
- component: {fileID: 1474109344}
|
||||
m_Layer: 3
|
||||
m_Name: Cube
|
||||
m_TagString: Untagged
|
||||
@@ -3974,184 +4161,33 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!43 &1683927177
|
||||
Mesh:
|
||||
--- !u!54 &1474109344
|
||||
Rigidbody:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: pb_Mesh-17466(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
|
||||
serializedVersion: 12
|
||||
m_SubMeshes:
|
||||
- serializedVersion: 2
|
||||
firstByte: 0
|
||||
indexCount: 36
|
||||
topology: 0
|
||||
baseVertex: 0
|
||||
firstVertex: 0
|
||||
vertexCount: 24
|
||||
localAABB:
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
m_Extent: {x: 0.025000006, y: 0.27861288, z: 0.025}
|
||||
m_Shapes:
|
||||
vertices: []
|
||||
shapes: []
|
||||
channels: []
|
||||
fullWeights: []
|
||||
m_BindPose: []
|
||||
m_BoneNameHashes:
|
||||
m_RootBoneNameHash: 0
|
||||
m_BonesAABB: []
|
||||
m_VariableBoneCountWeights:
|
||||
m_Data:
|
||||
m_MeshCompression: 0
|
||||
m_IsReadable: 1
|
||||
m_KeepVertices: 1
|
||||
m_KeepIndices: 1
|
||||
m_IndexFormat: 0
|
||||
m_IndexBuffer: 000001000200010003000200040005000600050007000600080009000a0009000b000a000c000d000e000d000f000e00100011001200110013001200140015001600150017001600
|
||||
m_VertexData:
|
||||
serializedVersion: 3
|
||||
m_VertexCount: 24
|
||||
m_Channels:
|
||||
- stream: 0
|
||||
offset: 0
|
||||
format: 0
|
||||
dimension: 3
|
||||
- stream: 0
|
||||
offset: 12
|
||||
format: 0
|
||||
dimension: 3
|
||||
- stream: 0
|
||||
offset: 24
|
||||
format: 0
|
||||
dimension: 4
|
||||
- stream: 0
|
||||
offset: 0
|
||||
format: 0
|
||||
dimension: 0
|
||||
- stream: 0
|
||||
offset: 40
|
||||
format: 0
|
||||
dimension: 2
|
||||
- stream: 0
|
||||
offset: 0
|
||||
format: 0
|
||||
dimension: 0
|
||||
- stream: 0
|
||||
offset: 0
|
||||
format: 0
|
||||
dimension: 0
|
||||
- stream: 0
|
||||
offset: 0
|
||||
format: 0
|
||||
dimension: 0
|
||||
- stream: 0
|
||||
offset: 0
|
||||
format: 0
|
||||
dimension: 0
|
||||
- stream: 0
|
||||
offset: 0
|
||||
format: 0
|
||||
dimension: 0
|
||||
- stream: 0
|
||||
offset: 0
|
||||
format: 0
|
||||
dimension: 0
|
||||
- stream: 0
|
||||
offset: 0
|
||||
format: 0
|
||||
dimension: 0
|
||||
- stream: 0
|
||||
offset: 0
|
||||
format: 0
|
||||
dimension: 0
|
||||
- stream: 0
|
||||
offset: 0
|
||||
format: 0
|
||||
dimension: 0
|
||||
m_DataSize: 1152
|
||||
_typelessdata: d0ccccbc59a68ebecdcccc3c00000000000000000000803f000080bf0000000000000000000080bfd0cc4c3d4fb3e23ed0cccc3c59a68ebecdcccc3c00000000000000000000803f000080bf0000000000000000000080bf000000004fb3e23ed0ccccbc59a68e3ecdcccc3c00000000000000000000803f000080bf0000000000000000000080bfd0cc4c3d0000803fd0cccc3c59a68e3ecdcccc3c00000000000000000000803f000080bf0000000000000000000080bf000000000000803fd0cccc3c59a68ebecdcccc3c0000803f000000000000000000000000000000000000803f000080bfcdcc4c3d4fb3e23ed0cccc3c59a68ebecdccccbc0000803f000000000000000000000000000000000000803f000080bf000000004fb3e23ed0cccc3c59a68e3ecdcccc3c0000803f000000000000000000000000000000000000803f000080bfcdcc4c3d0000803fd0cccc3c59a68e3ecdccccbc0000803f000000000000000000000000000000000000803f000080bf000000000000803fd0cccc3c59a68ebecdccccbc0000000000000000000080bf0000803f0000000000000000000080bfd0cc4c3d4fb3e23ed0ccccbc59a68ebecdccccbc0000000000000000000080bf0000803f0000000000000000000080bf000000004fb3e23ed0cccc3c59a68e3ecdccccbc0000000000000000000080bf0000803f0000000000000000000080bfd0cc4c3d0000803fd0ccccbc59a68e3ecdccccbc0000000000000000000080bf0000803f0000000000000000000080bf000000000000803fd0ccccbc59a68ebecdccccbc000080bf00000000000000000000000000000000000080bf000080bfcdcc4c3d4fb3e23ed0ccccbc59a68ebecdcccc3c000080bf00000000000000000000000000000000000080bf000080bf000000004fb3e23ed0ccccbc59a68e3ecdccccbc000080bf00000000000000000000000000000000000080bf000080bfcdcc4c3d0000803fd0ccccbc59a68e3ecdcccc3c000080bf00000000000000000000000000000000000080bf000080bf000000000000803fd0ccccbc59a68e3ecdcccc3c000000000000803f000000000000803f0000000000000000000080bf000000000000803fd0cccc3c59a68e3ecdcccc3c000000000000803f000000000000803f0000000000000000000080bfd0cc4c3d0000803fd0ccccbc59a68e3ecdccccbc000000000000803f000000000000803f0000000000000000000080bf000000003433733fd0cccc3c59a68e3ecdccccbc000000000000803f000000000000803f0000000000000000000080bfd0cc4c3d3433733fd0ccccbc59a68ebecdccccbc00000000000080bf00000000000080bf0000000000000000000080bfd0cc4c3d3433733fd0cccc3c59a68ebecdccccbc00000000000080bf00000000000080bf0000000000000000000080bf000000003433733fd0ccccbc59a68ebecdcccc3c00000000000080bf00000000000080bf0000000000000000000080bfd0cc4c3d0000803fd0cccc3c59a68ebecdcccc3c00000000000080bf00000000000080bf0000000000000000000080bf000000000000803f
|
||||
m_CompressedMesh:
|
||||
m_Vertices:
|
||||
m_NumItems: 0
|
||||
m_Range: 0
|
||||
m_Start: 0
|
||||
m_Data:
|
||||
m_BitSize: 0
|
||||
m_UV:
|
||||
m_NumItems: 0
|
||||
m_Range: 0
|
||||
m_Start: 0
|
||||
m_Data:
|
||||
m_BitSize: 0
|
||||
m_Normals:
|
||||
m_NumItems: 0
|
||||
m_Range: 0
|
||||
m_Start: 0
|
||||
m_Data:
|
||||
m_BitSize: 0
|
||||
m_Tangents:
|
||||
m_NumItems: 0
|
||||
m_Range: 0
|
||||
m_Start: 0
|
||||
m_Data:
|
||||
m_BitSize: 0
|
||||
m_Weights:
|
||||
m_NumItems: 0
|
||||
m_Data:
|
||||
m_BitSize: 0
|
||||
m_NormalSigns:
|
||||
m_NumItems: 0
|
||||
m_Data:
|
||||
m_BitSize: 0
|
||||
m_TangentSigns:
|
||||
m_NumItems: 0
|
||||
m_Data:
|
||||
m_BitSize: 0
|
||||
m_FloatColors:
|
||||
m_NumItems: 0
|
||||
m_Range: 0
|
||||
m_Start: 0
|
||||
m_Data:
|
||||
m_BitSize: 0
|
||||
m_BoneIndices:
|
||||
m_NumItems: 0
|
||||
m_Data:
|
||||
m_BitSize: 0
|
||||
m_Triangles:
|
||||
m_NumItems: 0
|
||||
m_Data:
|
||||
m_BitSize: 0
|
||||
m_UVInfo: 0
|
||||
m_LocalAABB:
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
m_Extent: {x: 0.025000006, y: 0.27861288, z: 0.025}
|
||||
m_MeshUsageFlags: 0
|
||||
m_CookingOptions: 30
|
||||
m_BakedConvexCollisionMesh:
|
||||
m_BakedTriangleCollisionMesh:
|
||||
'm_MeshMetrics[0]': 1.000001
|
||||
'm_MeshMetrics[1]': 1
|
||||
m_MeshOptimizationFlags: 1
|
||||
m_StreamData:
|
||||
m_GameObject: {fileID: 1474109339}
|
||||
serializedVersion: 5
|
||||
m_Mass: 5
|
||||
m_LinearDamping: 0
|
||||
m_AngularDamping: 0.05
|
||||
m_CenterOfMass: {x: 0, y: 0, z: 0}
|
||||
m_InertiaTensor: {x: 1, y: 1, z: 1}
|
||||
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
offset: 0
|
||||
size: 0
|
||||
path:
|
||||
m_MeshLodInfo:
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_LodSelectionCurve:
|
||||
serializedVersion: 1
|
||||
m_LodSlope: 0
|
||||
m_LodBias: 0
|
||||
m_NumLevels: 1
|
||||
m_SubMeshes:
|
||||
- serializedVersion: 2
|
||||
m_Levels:
|
||||
- serializedVersion: 1
|
||||
m_IndexStart: 0
|
||||
m_IndexCount: 0
|
||||
m_Bits: 0
|
||||
m_ImplicitCom: 1
|
||||
m_ImplicitTensor: 1
|
||||
m_UseGravity: 1
|
||||
m_IsKinematic: 0
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 0
|
||||
m_CollisionDetection: 0
|
||||
--- !u!1 &2008019735
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
public class TestScript2 : MonoBehaviour
|
||||
public class UpperPump : MonoBehaviour
|
||||
{
|
||||
private Rigidbody _rigidbody;
|
||||
private InputAction _moveAction;
|
||||
@@ -12,83 +10,50 @@ public class TestScript2 : MonoBehaviour
|
||||
|
||||
private Action _jumpTimerFinished;
|
||||
|
||||
private ConfigurableJoint _configurableJoint;
|
||||
|
||||
private float _smoothX;
|
||||
|
||||
private double _maxDifference = 0;
|
||||
private double _initDifference = 0;
|
||||
private double _maxDifference;
|
||||
private double _initDifference;
|
||||
|
||||
private bool _grounded = false;
|
||||
private bool _jumpQueued = false;
|
||||
private bool _jumped = false;
|
||||
private bool _grounded;
|
||||
private bool _jumpQueued;
|
||||
private bool _justJumped;
|
||||
private bool _canJump = true;
|
||||
private bool _shouldJump = false;
|
||||
private bool _shouldJump;
|
||||
|
||||
private float _jumpTimer = 0f;
|
||||
private bool _useDampedTorque = false;
|
||||
private float _jumpTimer;
|
||||
|
||||
private double? _previousDifference = null;
|
||||
private double? _previousDifference;
|
||||
|
||||
private float _angularDamping;
|
||||
[Header("Jumping values")]
|
||||
|
||||
[SerializeField]
|
||||
private float jumpingAngularDamping = 250f;
|
||||
[SerializeField] private float jumpingAngularDamping = 250f;
|
||||
|
||||
[SerializeField]
|
||||
private float jumpTimerMilliseconds = 450f;
|
||||
[SerializeField] private float jumpTimerMilliseconds = 450f;
|
||||
|
||||
[SerializeField]
|
||||
private float torqueForce = 8;
|
||||
[SerializeField] private float torqueForce = 8;
|
||||
|
||||
[SerializeField]
|
||||
private float lerpSpeed = 7;
|
||||
[SerializeField] private float lerpSpeed = 7;
|
||||
|
||||
[SerializeField]
|
||||
private float jumpDownForce = 3.5f;
|
||||
[SerializeField] private float jumpDownForce = 3.5f;
|
||||
|
||||
[SerializeField]
|
||||
private float jumpUpForce = 3.5f;
|
||||
[SerializeField] private float jumpUpForce = 3.5f;
|
||||
|
||||
[SerializeField]
|
||||
private ForceMode forceMode = ForceMode.VelocityChange;
|
||||
[SerializeField] private ForceMode rotationForceMode = ForceMode.VelocityChange;
|
||||
|
||||
[SerializeField]
|
||||
private Rigidbody pump;
|
||||
[SerializeField] private bool lerp = true;
|
||||
|
||||
[SerializeField]
|
||||
private DebugUi debugUi;
|
||||
[Header("Other")]
|
||||
|
||||
[SerializeField]
|
||||
private float timeScale = 1f;
|
||||
[SerializeField] private DebugUi debugUi;
|
||||
|
||||
[SerializeField]
|
||||
private bool lerp = true;
|
||||
[SerializeField] private float timeScale = 1f;
|
||||
|
||||
[SerializeField]
|
||||
private LayerMask layerMask;
|
||||
[SerializeField] private BottomPump bottomPump;
|
||||
|
||||
|
||||
private void Awake()
|
||||
private void GroundedChanged(bool newGroundedState)
|
||||
{
|
||||
_rigidbody = GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_moveAction = InputSystem.actions.FindAction("Move");
|
||||
_jumpAction = InputSystem.actions.FindAction("Jump");
|
||||
|
||||
_moveAction.Enable();
|
||||
_jumpAction.Enable();
|
||||
|
||||
_maxDifference = GetDifference();
|
||||
_initDifference = _maxDifference;
|
||||
|
||||
_jumpTimerFinished += JumpTimerFinished;
|
||||
_angularDamping = _rigidbody.angularDamping;
|
||||
|
||||
Time.timeScale = timeScale;
|
||||
_grounded = newGroundedState;
|
||||
}
|
||||
|
||||
private void JumpTimerFinished()
|
||||
@@ -99,7 +64,7 @@ public class TestScript2 : MonoBehaviour
|
||||
private double GetDifference()
|
||||
{
|
||||
Vector3 axis = transform.up; // this transform's local Y in world space
|
||||
Vector3 toOther = pump.transform.position - transform.position;
|
||||
Vector3 toOther = bottomPump.transform.position - transform.position;
|
||||
|
||||
var val = Vector3.Dot(toOther, axis);
|
||||
|
||||
@@ -114,18 +79,30 @@ public class TestScript2 : MonoBehaviour
|
||||
float t = Mathf.InverseLerp(0.15f, 0.63f, (float)_maxDifference); // gives 0 when 0.63, 1 when 0.15
|
||||
float forceMultiplier = Mathf.Lerp(30, 5, t);
|
||||
|
||||
_justJumped = true;
|
||||
|
||||
ResetValues();
|
||||
|
||||
StartJumpTimer();
|
||||
|
||||
_rigidbody.AddForce(transform.up * (jumpUpForce * forceMultiplier), ForceMode.Impulse);
|
||||
}
|
||||
|
||||
private void StartJumpTimer()
|
||||
{
|
||||
_jumpTimer = jumpTimerMilliseconds / 1000;
|
||||
}
|
||||
|
||||
private void ResetValues()
|
||||
{
|
||||
_maxDifference = _initDifference;
|
||||
_previousDifference = null;
|
||||
_jumpQueued = false;
|
||||
_shouldJump = false;
|
||||
_jumped = true;
|
||||
_canJump = false;
|
||||
_jumpTimer = jumpTimerMilliseconds / 1000;
|
||||
|
||||
pump.AddForce(transform.up * (jumpUpForce * forceMultiplier), ForceMode.Impulse);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
private void RunJumpTimer()
|
||||
{
|
||||
if (_jumpTimer > 0) {
|
||||
_jumpTimer -= Time.deltaTime;
|
||||
@@ -135,7 +112,10 @@ public class TestScript2 : MonoBehaviour
|
||||
_jumpTimerFinished?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetSmoothX()
|
||||
{
|
||||
var moveValue = _moveAction.ReadValue<Vector2>();
|
||||
|
||||
if (moveValue.x != 0) {
|
||||
@@ -143,15 +123,21 @@ public class TestScript2 : MonoBehaviour
|
||||
} else {
|
||||
_smoothX = 0;
|
||||
}
|
||||
|
||||
debugUi.UpdateText("Rotation Z", _rigidbody.rotation.eulerAngles.z.ToString());
|
||||
debugUi.UpdateText("Angular damping", _rigidbody.angularDamping.ToString());
|
||||
|
||||
if ((_jumped && !_grounded) || _jumpAction.WasReleasedThisFrame()) {
|
||||
_jumped = false;
|
||||
}
|
||||
|
||||
if (_jumpAction.IsPressed() && _grounded && !_jumped && _canJump) {
|
||||
private void DebugUi()
|
||||
{
|
||||
debugUi.UpdateText("Rotation Z", _rigidbody.rotation.eulerAngles.z.ToString());
|
||||
debugUi.UpdateText("Angular damping", _rigidbody.angularDamping.ToString());
|
||||
}
|
||||
|
||||
private void HandleJumpingStates()
|
||||
{
|
||||
if ((_justJumped && !_grounded) || _jumpAction.WasReleasedThisFrame()) {
|
||||
_justJumped = false;
|
||||
}
|
||||
|
||||
if (_jumpAction.IsPressed() && _grounded && !_justJumped && _canJump) {
|
||||
_jumpQueued = true;
|
||||
}
|
||||
|
||||
@@ -170,10 +156,47 @@ public class TestScript2 : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* EVENT FUNCTIONS
|
||||
*/
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_rigidbody = GetComponent<Rigidbody>();
|
||||
|
||||
bottomPump.GroundedChanged += GroundedChanged;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_moveAction = InputSystem.actions.FindAction("Move");
|
||||
_jumpAction = InputSystem.actions.FindAction("Jump");
|
||||
|
||||
_moveAction.Enable();
|
||||
_jumpAction.Enable();
|
||||
|
||||
_maxDifference = GetDifference();
|
||||
_initDifference = _maxDifference;
|
||||
|
||||
_jumpTimerFinished += JumpTimerFinished;
|
||||
|
||||
Time.timeScale = timeScale;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
RunJumpTimer();
|
||||
|
||||
SetSmoothX();
|
||||
|
||||
DebugUi();
|
||||
|
||||
HandleJumpingStates();
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
// inverted to apply correct direction
|
||||
_rigidbody.AddTorque(new Vector3(0, 0, -_smoothX) * torqueForce, forceMode);
|
||||
_rigidbody.AddTorque(new Vector3(0, 0, -_smoothX) * torqueForce, rotationForceMode);
|
||||
|
||||
if (_jumpQueued) {
|
||||
_rigidbody.AddForce(-transform.up * jumpDownForce, ForceMode.Impulse);
|
||||
@@ -182,17 +205,5 @@ public class TestScript2 : MonoBehaviour
|
||||
Jump();
|
||||
}
|
||||
}
|
||||
|
||||
var origin = pump.position;
|
||||
var dir = -pump.transform.up; // world down
|
||||
const float distance = .35f;
|
||||
|
||||
if (Physics.Raycast(origin, dir, out var hit, distance, layerMask.value)) {
|
||||
Debug.DrawRay(origin, dir * hit.distance, Color.yellow);
|
||||
_grounded = true;
|
||||
} else {
|
||||
Debug.DrawRay(origin, dir * distance, Color.white);
|
||||
_grounded = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
8
Assets/_Recovery.meta
Normal file
8
Assets/_Recovery.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c1500a7f28237c9499ea4b9f951190a0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
4199
Assets/_Recovery/0.unity
Normal file
4199
Assets/_Recovery/0.unity
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/_Recovery/0.unity.meta
Normal file
7
Assets/_Recovery/0.unity.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 27184a9ba3023fc4fa7763a00b00de07
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -86,6 +86,7 @@ PlayerSettings:
|
||||
muteOtherAudioSources: 0
|
||||
Prepare IOS For Recording: 0
|
||||
Force IOS Speakers When Recording: 0
|
||||
audioSpatialExperience: 0
|
||||
deferSystemGesturesMode: 0
|
||||
hideHomeButton: 0
|
||||
submitAnalytics: 1
|
||||
@@ -531,6 +532,9 @@ PlayerSettings:
|
||||
- m_BuildTarget: AndroidPlayer
|
||||
m_APIs: 150000000b000000
|
||||
m_Automatic: 0
|
||||
- m_BuildTarget: WindowsStandaloneSupport
|
||||
m_APIs: 0200000012000000
|
||||
m_Automatic: 0
|
||||
m_BuildTargetVRSettings: []
|
||||
m_DefaultShaderChunkSizeInMB: 16
|
||||
m_DefaultShaderChunkCount: 0
|
||||
|
||||
Reference in New Issue
Block a user