fuck moving platforms

This commit is contained in:
OverflowNarhoym
2022-02-25 21:33:29 +01:00
parent 75ea014fbf
commit 07a542a990
5 changed files with 90 additions and 64 deletions

View File

@@ -95,19 +95,19 @@ Rigidbody2D:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3453266731971349118}
m_BodyType: 2
m_BodyType: 1
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 1
m_GravityScale: 0
m_Material: {fileID: 0}
m_Interpolate: 0
m_Interpolate: 1
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 0
m_CollisionDetection: 1
m_Constraints: 4
--- !u!61 &3453266731971349116
BoxCollider2D:
m_ObjectHideFlags: 0
@@ -146,5 +146,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 1637c8c06cf9fae4eb7bfa1a0ebb0e55, type: 3}
m_Name:
m_EditorClassIdentifier:
xOffset: 10
xOffset: 5
yOffset: 0
speed: 0.05

View File

@@ -26,7 +26,7 @@ Transform:
m_GameObject: {fileID: 698768804}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.5, y: 0, z: 0}
m_LocalScale: {x: 0.1, y: 2, z: 1}
m_LocalScale: {x: 0.1, y: 1.3, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7008207192594766311}
@@ -73,7 +73,7 @@ Transform:
m_GameObject: {fileID: 2083070160}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.5, y: 0, z: 0}
m_LocalScale: {x: 0.1, y: 2, z: 1}
m_LocalScale: {x: 0.1, y: 1.3, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7008207192594766311}

View File

@@ -176,31 +176,11 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349115, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_BodyType
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349115, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_Constraints
value: 4
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349115, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_Interpolate
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349115, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_GravityScale
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349115, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_CollisionDetection
value: 1
value: 2
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349117, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: speed
value: 0.05
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349117, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: xOffset
value: 5
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349118, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_Name
@@ -208,6 +188,11 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
--- !u!4 &175005001 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
m_PrefabInstance: {fileID: 53543450}
m_PrefabAsset: {fileID: 0}
--- !u!1 &387708699
GameObject:
m_ObjectHideFlags: 0
@@ -2610,6 +2595,53 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 85e13cc38c9c13145bdb0c612c6e2cbe, type: 3}
--- !u!1 &1023957098
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1023957099}
- component: {fileID: 1023957100}
m_Layer: 3
m_Name: MovingPlatformTrigger
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1023957099
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1023957098}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0.55, z: 0}
m_LocalScale: {x: 6, y: 0.1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 175005001}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1023957100
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1023957098}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7000c8c0eb91b2d4cb9a0e3ee1b609a7, type: 3}
m_Name:
m_EditorClassIdentifier:
layerMask:
serializedVersion: 2
m_Bits: 4294966848
--- !u!4 &1053905692 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 7008207192594766311, guid: 2ed6bfce9ad3e19428cb9bef743e0fa3, type: 3}
@@ -3056,22 +3088,10 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 698768805, guid: 2ed6bfce9ad3e19428cb9bef743e0fa3, type: 3}
propertyPath: m_LocalScale.y
value: 1.5
objectReference: {fileID: 0}
- target: {fileID: 2083070161, guid: 2ed6bfce9ad3e19428cb9bef743e0fa3, type: 3}
propertyPath: m_LocalScale.y
value: 1.5
objectReference: {fileID: 0}
- target: {fileID: 7008207192594766305, guid: 2ed6bfce9ad3e19428cb9bef743e0fa3, type: 3}
propertyPath: m_Name
value: Player
objectReference: {fileID: 0}
- target: {fileID: 7008207192594766310, guid: 2ed6bfce9ad3e19428cb9bef743e0fa3, type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7008207192594766311, guid: 2ed6bfce9ad3e19428cb9bef743e0fa3, type: 3}
propertyPath: m_RootOrder
value: 2

View File

@@ -17,10 +17,12 @@ namespace Platforms
private bool _goingToFuturePos;
private Rigidbody2D _platformRigidbody;
private CollisionChecker _movingPlatformTrigger;
private void Awake()
{
_platformRigidbody = GetComponent<Rigidbody2D>();
_movingPlatformTrigger = GetComponentInChildren<CollisionChecker>();
}
private void Start()
@@ -58,19 +60,22 @@ namespace Platforms
public void Move(float value)
{
var position = transform.position;
//var position = transform.position;
switch (_goingToFuturePos)
{
case true:
_platformRigidbody.MovePosition(new Vector2(position.x + speed * GetDecision(xOffset),
position.y + speed * GetDecision(yOffset)));
//_platformRigidbody.MovePosition(new Vector2(position.x + speed * GetDecision(xOffset),
//position.y + speed * GetDecision(yOffset)));
transform.position = Vector3.MoveTowards(transform.position, _futurePos, speed * Time.deltaTime);
if (Math.Abs(_futurePos.x - transform.position.x) < VerificationOffset &&
Math.Abs(_futurePos.y - transform.position.y) < VerificationOffset)
_goingToFuturePos = false;
break;
case false:
_platformRigidbody.MovePosition(new Vector2(position.x + speed * -GetDecision(xOffset),
position.y + speed * -GetDecision(yOffset)));
//_platformRigidbody.MovePosition(new Vector2(position.x + speed * -GetDecision(xOffset),
//position.y + speed * -GetDecision(yOffset)));
transform.position = Vector3.MoveTowards(transform.position, _originalPos, speed * Time.deltaTime);
if (Math.Abs(_originalPos.x - transform.position.x) < VerificationOffset &&
Math.Abs(_originalPos.y - transform.position.y) < VerificationOffset)
_goingToFuturePos = true;