Main Menu Edits and hopefully fixing block push bug

main
thoopchuk26 4 years ago
parent dc2dfeafce
commit 7616385923

@ -1180,7 +1180,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -28, y: 145} m_AnchoredPosition: {x: -28, y: 107}
m_SizeDelta: {x: 200, y: 50} m_SizeDelta: {x: 200, y: 50}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &655160809 --- !u!114 &655160809
@ -1203,7 +1203,7 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_text: Windgate Museum Demo Game m_text: Art-tastrophe
m_isRightToLeft: 0 m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2100000, guid: e73a58f6e2794ae7b1b7e50b7fb811b0, type: 2} m_sharedMaterial: {fileID: 2100000, guid: e73a58f6e2794ae7b1b7e50b7fb811b0, type: 2}

@ -7,13 +7,16 @@ public class blockPush : MonoBehaviour
public bool canPush = false; public bool canPush = false;
private Rigidbody2D blockrb2d; private Rigidbody2D blockrb2d;
private CircleCollider2D cc2d;
public float pushPower = 2.0f; public float pushPower = 2.0f;
private float pushVar;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
cc2d = GetComponent<CircleCollider2D>();
pushVar = pushPower;
} }
// Update is called once per frame // Update is called once per frame
@ -30,12 +33,25 @@ public class blockPush : MonoBehaviour
blockrb2d = collision.collider.GetComponent<Rigidbody2D>(); blockrb2d = collision.collider.GetComponent<Rigidbody2D>();
if (GetComponent<movement>().faceRight) if (GetComponent<movement>().faceRight)
{ {
blockrb2d.MovePosition(new Vector2(blockrb2d.position.x + pushPower/100, blockrb2d.position.y)); blockrb2d.MovePosition(new Vector2(blockrb2d.position.x + pushVar/100, blockrb2d.position.y));
} }
else if (!GetComponent<movement>().faceRight) else if (!GetComponent<movement>().faceRight)
{ {
blockrb2d.MovePosition(new Vector2(blockrb2d.position.x - pushPower/100, blockrb2d.position.y)); blockrb2d.MovePosition(new Vector2(blockrb2d.position.x - pushVar/ 100, blockrb2d.position.y));
} }
} }
} }
private void OnTriggerEnter2D(Collider2D collision)
{
if(collision.tag == "Block")
{
pushVar = 0;
}
}
private void OnTriggerExit2D(Collider2D collision)
{
pushVar = pushPower;
}
} }

Loading…
Cancel
Save