Fix for incorrect grounded check when moving between tetromino pieces.
This commit is contained in:
parent
83ab22c965
commit
bea57e1da1
8 changed files with 29 additions and 18 deletions
|
@ -11,7 +11,7 @@ GameObject:
|
|||
- component: {fileID: 6236062734293464139}
|
||||
- component: {fileID: 376557520294348530}
|
||||
- component: {fileID: 6834817323510214274}
|
||||
m_Layer: 0
|
||||
m_Layer: 3
|
||||
m_Name: tetrominoBase
|
||||
m_TagString: Tetromino
|
||||
m_Icon: {fileID: 0}
|
||||
|
@ -26,7 +26,7 @@ Transform:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6737607240575143600}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: -0.5, y: 0.5, z: 1.0833299}
|
||||
m_LocalPosition: {x: -0.5, y: 0.5, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
|
|
|
@ -49,6 +49,7 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
timeBetweenSteps: 1
|
||||
active: 1
|
||||
TetrominoUserControl: {fileID: 0}
|
||||
--- !u!1001 &4137620469026440380
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -74,7 +75,7 @@ PrefabInstance:
|
|||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 1.0833299
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
|
@ -149,7 +150,7 @@ PrefabInstance:
|
|||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 1.0833299
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
|
@ -224,7 +225,7 @@ PrefabInstance:
|
|||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 1.0833299
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
|
@ -299,7 +300,7 @@ PrefabInstance:
|
|||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 1.0833299
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
|
|
|
@ -49,6 +49,7 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
timeBetweenSteps: 1
|
||||
active: 1
|
||||
TetrominoUserControl: {fileID: 0}
|
||||
--- !u!1001 &1367507823977501540
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -74,7 +75,7 @@ PrefabInstance:
|
|||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 1.0833299
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
|
@ -149,7 +150,7 @@ PrefabInstance:
|
|||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 1.0833299
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
|
@ -224,7 +225,7 @@ PrefabInstance:
|
|||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 1.0833299
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
|
@ -299,7 +300,7 @@ PrefabInstance:
|
|||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 1.0833299
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
|
|
|
@ -49,6 +49,7 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
timeBetweenSteps: 1
|
||||
active: 1
|
||||
TetrominoUserControl: {fileID: 0}
|
||||
--- !u!1001 &1397972397338354504
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -74,7 +75,7 @@ PrefabInstance:
|
|||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 1.0833299
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
|
@ -149,7 +150,7 @@ PrefabInstance:
|
|||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 1.0833299
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
|
@ -224,7 +225,7 @@ PrefabInstance:
|
|||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 1.0833299
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
|
@ -299,7 +300,7 @@ PrefabInstance:
|
|||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 1.0833299
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6236062734293464139, guid: e48be30fa7d49ee48891616387d00ef4,
|
||||
type: 3}
|
||||
|
|
|
@ -259,7 +259,7 @@ MonoBehaviour:
|
|||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
moveSpeed: 10
|
||||
jumpForce: 8
|
||||
jumpForce: 15
|
||||
isGrounded: 0
|
||||
--- !u!61 &389734759
|
||||
BoxCollider2D:
|
||||
|
|
|
@ -5,15 +5,18 @@ using UnityEngine;
|
|||
public class GroundCheck : MonoBehaviour
|
||||
{
|
||||
GameObject Player;
|
||||
private LayerMask solidLayer;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Player = gameObject.transform.parent.gameObject;
|
||||
solidLayer = LayerMask.GetMask("SolidObject");
|
||||
}
|
||||
private void OnCollisionEnter2D(Collision2D collision)
|
||||
{
|
||||
if (collision.collider.tag == "Ground" || collision.collider.tag == "Platform" || collision.collider.tag == "Tetromino")
|
||||
{
|
||||
Debug.Log("Now standing on "+ collision.collider.name);
|
||||
Player.GetComponent<Movement2D>().isGrounded = true;
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +25,11 @@ public class GroundCheck : MonoBehaviour
|
|||
{
|
||||
if (collision.collider.tag == "Ground" || collision.collider.tag == "Platform" || collision.collider.tag == "Tetromino")
|
||||
{
|
||||
Player.GetComponent<Movement2D>().isGrounded = false;
|
||||
if (GetComponent<BoxCollider2D>().IsTouchingLayers(solidLayer) == false)
|
||||
{
|
||||
Debug.Log("No longer standing on " + collision.collider.name);
|
||||
Player.GetComponent<Movement2D>().isGrounded = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public class tetrominoSpawnManager : MonoBehaviour
|
|||
public GameObject tetrominoZ;
|
||||
|
||||
private int nextTetromino = 0;
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
|
|
@ -6,11 +6,12 @@ TagManager:
|
|||
tags:
|
||||
- Ground
|
||||
- Platform
|
||||
- Tetromino
|
||||
layers:
|
||||
- Default
|
||||
- TransparentFX
|
||||
- Ignore Raycast
|
||||
-
|
||||
- SolidObject
|
||||
- Water
|
||||
- UI
|
||||
-
|
||||
|
|
Loading…
Reference in a new issue