Refactored and reworked mouse based triggers to remove some funky pickup/drop bugs for cleaning items
This commit is contained in:
@@ -297,7 +297,7 @@ GameObject:
|
|||||||
- component: {fileID: 1425971016}
|
- component: {fileID: 1425971016}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Background
|
m_Name: Background
|
||||||
m_TagString: Untagged
|
m_TagString: Background
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
|
|||||||
@@ -36,10 +36,8 @@ public class GameScript : MonoBehaviour
|
|||||||
Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y);
|
Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y);
|
||||||
RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero);
|
RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero);
|
||||||
|
|
||||||
if (hit.collider != null)
|
|
||||||
{
|
|
||||||
|
|
||||||
if(hit.collider.gameObject.tag == "Restart" && gameOver)
|
if(hit.collider != null && hit.collider.gameObject.tag == "Restart" && gameOver)
|
||||||
{
|
{
|
||||||
|
|
||||||
Restart.SetActive(false);
|
Restart.SetActive(false);
|
||||||
@@ -51,13 +49,13 @@ public class GameScript : MonoBehaviour
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hit.collider.gameObject.tag == "Item" && !clicked && !gameOver)
|
if (hit.collider != null && hit.collider.gameObject.tag == "Item" && !clicked && !gameOver)
|
||||||
{
|
{
|
||||||
pickedUpItem = hit.collider.gameObject;
|
pickedUpItem = hit.collider.gameObject;
|
||||||
clicked = true;
|
clicked = true;
|
||||||
Cursor.visible = false;
|
Cursor.visible = false;
|
||||||
|
|
||||||
} else if (hit.collider.gameObject.tag == "Item" && clicked)
|
} else if (hit.collider != null && clicked)
|
||||||
{
|
{
|
||||||
clicked = false;
|
clicked = false;
|
||||||
Cursor.visible = true;
|
Cursor.visible = true;
|
||||||
@@ -77,8 +75,6 @@ public class GameScript : MonoBehaviour
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ TagManager:
|
|||||||
- Item
|
- Item
|
||||||
- Dirt
|
- Dirt
|
||||||
- Restart
|
- Restart
|
||||||
|
- Background
|
||||||
layers:
|
layers:
|
||||||
- Default
|
- Default
|
||||||
- TransparentFX
|
- TransparentFX
|
||||||
|
|||||||
Reference in New Issue
Block a user