Fix for tetrominoes falling partway through the floor.

This commit is contained in:
Kaj Forney 2021-10-08 20:58:19 -06:00
parent 184524db56
commit feda7a1a8a
Signed by: kforney
GPG key ID: 3AB4E2E04CEF656F
5 changed files with 63 additions and 64 deletions

View file

@ -70,6 +70,7 @@ public class tetromino : MonoBehaviour
private bool validateFall(Transform pieceToCheck) //returns true if the next step collides with something private bool validateFall(Transform pieceToCheck) //returns true if the next step collides with something
{ {
//Cast a ray to the next position of the tetromino. //Cast a ray to the next position of the tetromino.
//NOTE: disabled "Queries Start in Colliders" in Project Settings>Physics 2D (thank you again, Tavi).
RaycastHit2D collision = Physics2D.Raycast(pieceToCheck.position, Vector2.down, 1.0f); RaycastHit2D collision = Physics2D.Raycast(pieceToCheck.position, Vector2.down, 1.0f);
Debug.DrawRay(pieceToCheck.position,Vector3.down,Color.red,1000.0f); Debug.DrawRay(pieceToCheck.position,Vector3.down,Color.red,1000.0f);
if (collision.collider != null && collision.collider.name != pieceToCheck.name) if (collision.collider != null && collision.collider.name != pieceToCheck.name)
@ -83,10 +84,8 @@ public class tetromino : MonoBehaviour
} }
return true; return true;
} }
else
{ return false;
return false;
}
} }
void Fall() void Fall()

View file

@ -6,7 +6,7 @@
"com.unity.2d.sprite": "1.0.0", "com.unity.2d.sprite": "1.0.0",
"com.unity.2d.spriteshape": "6.0.1", "com.unity.2d.spriteshape": "6.0.1",
"com.unity.2d.tilemap": "1.0.0", "com.unity.2d.tilemap": "1.0.0",
"com.unity.collab-proxy": "1.9.0", "com.unity.collab-proxy": "1.11.2",
"com.unity.ide.rider": "3.0.7", "com.unity.ide.rider": "3.0.7",
"com.unity.ide.visualstudio": "2.0.11", "com.unity.ide.visualstudio": "2.0.11",
"com.unity.ide.vscode": "1.2.4", "com.unity.ide.vscode": "1.2.4",

View file

@ -73,7 +73,7 @@
"dependencies": {} "dependencies": {}
}, },
"com.unity.collab-proxy": { "com.unity.collab-proxy": {
"version": "1.9.0", "version": "1.11.2",
"depth": 0, "depth": 0,
"source": "registry", "source": "registry",
"dependencies": {}, "dependencies": {},

View file

@ -1,56 +1,56 @@
%YAML 1.1 %YAML 1.1
%TAG !u! tag:unity3d.com,2011: %TAG !u! tag:unity3d.com,2011:
--- !u!19 &1 --- !u!19 &1
Physics2DSettings: Physics2DSettings:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 4 serializedVersion: 5
m_Gravity: {x: 0, y: -9.81} m_Gravity: {x: 0, y: -9.81}
m_DefaultMaterial: {fileID: 0} m_DefaultMaterial: {fileID: 0}
m_VelocityIterations: 8 m_VelocityIterations: 8
m_PositionIterations: 3 m_PositionIterations: 3
m_VelocityThreshold: 1 m_VelocityThreshold: 1
m_MaxLinearCorrection: 0.2 m_MaxLinearCorrection: 0.2
m_MaxAngularCorrection: 8 m_MaxAngularCorrection: 8
m_MaxTranslationSpeed: 100 m_MaxTranslationSpeed: 100
m_MaxRotationSpeed: 360 m_MaxRotationSpeed: 360
m_BaumgarteScale: 0.2 m_BaumgarteScale: 0.2
m_BaumgarteTimeOfImpactScale: 0.75 m_BaumgarteTimeOfImpactScale: 0.75
m_TimeToSleep: 0.5 m_TimeToSleep: 0.5
m_LinearSleepTolerance: 0.01 m_LinearSleepTolerance: 0.01
m_AngularSleepTolerance: 2 m_AngularSleepTolerance: 2
m_DefaultContactOffset: 0.01 m_DefaultContactOffset: 0.01
m_JobOptions: m_JobOptions:
serializedVersion: 2 serializedVersion: 2
useMultithreading: 0 useMultithreading: 0
useConsistencySorting: 0 useConsistencySorting: 0
m_InterpolationPosesPerJob: 100 m_InterpolationPosesPerJob: 100
m_NewContactsPerJob: 30 m_NewContactsPerJob: 30
m_CollideContactsPerJob: 100 m_CollideContactsPerJob: 100
m_ClearFlagsPerJob: 200 m_ClearFlagsPerJob: 200
m_ClearBodyForcesPerJob: 200 m_ClearBodyForcesPerJob: 200
m_SyncDiscreteFixturesPerJob: 50 m_SyncDiscreteFixturesPerJob: 50
m_SyncContinuousFixturesPerJob: 50 m_SyncContinuousFixturesPerJob: 50
m_FindNearestContactsPerJob: 100 m_FindNearestContactsPerJob: 100
m_UpdateTriggerContactsPerJob: 100 m_UpdateTriggerContactsPerJob: 100
m_IslandSolverCostThreshold: 100 m_IslandSolverCostThreshold: 100
m_IslandSolverBodyCostScale: 1 m_IslandSolverBodyCostScale: 1
m_IslandSolverContactCostScale: 10 m_IslandSolverContactCostScale: 10
m_IslandSolverJointCostScale: 10 m_IslandSolverJointCostScale: 10
m_IslandSolverBodiesPerJob: 50 m_IslandSolverBodiesPerJob: 50
m_IslandSolverContactsPerJob: 50 m_IslandSolverContactsPerJob: 50
m_AutoSimulation: 1 m_SimulationMode: 0
m_QueriesHitTriggers: 1 m_QueriesHitTriggers: 1
m_QueriesStartInColliders: 1 m_QueriesStartInColliders: 0
m_CallbacksOnDisable: 1 m_CallbacksOnDisable: 1
m_ReuseCollisionCallbacks: 1 m_ReuseCollisionCallbacks: 1
m_AutoSyncTransforms: 0 m_AutoSyncTransforms: 0
m_AlwaysShowColliders: 0 m_AlwaysShowColliders: 0
m_ShowColliderSleep: 1 m_ShowColliderSleep: 1
m_ShowColliderContacts: 0 m_ShowColliderContacts: 0
m_ShowColliderAABB: 0 m_ShowColliderAABB: 0
m_ContactArrowScale: 0.2 m_ContactArrowScale: 0.2
m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412}
m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432}
m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745}
m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804}
m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

View file

@ -1,2 +1,2 @@
m_EditorVersion: 2021.1.22f1 m_EditorVersion: 2021.1.24f1
m_EditorVersionWithRevision: 2021.1.22f1 (a137e5fb0427) m_EditorVersionWithRevision: 2021.1.24f1 (6667702a1e7c)