Commit 7a9bcf5c authored by Mitchie Maluschnig's avatar Mitchie Maluschnig
Browse files

Prototype Complete. fixed bug where trapeze would trigger imediatly after...

Prototype Complete. fixed bug where trapeze would trigger imediatly after letting go (now waits 0.5 sec).
parent 6b0e4e48
......@@ -377,7 +377,7 @@ CapsuleCollider2D:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 597797147}
m_Enabled: 0
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 1
......@@ -451,7 +451,7 @@ EdgeCollider2D:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 597797147}
m_Enabled: 1
m_Enabled: 0
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 1
......@@ -1032,6 +1032,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: e8199870fdccbda429d8da476630df26, type: 3}
m_Name:
m_EditorClassIdentifier:
trapezeCooldown: 0.5
--- !u!1 &1910743195
GameObject:
m_ObjectHideFlags: 0
......@@ -1407,7 +1408,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
swingForce: 40
rotateForce: 2
exitForce: 3
exitForce: 2
handsPivot: {fileID: 1858953468}
midPivot: {fileID: 95257390}
botPivot: {fileID: 859786666}
......
......@@ -3,8 +3,11 @@ using System.Collections.Generic;
using UnityEngine;
public class HandsTrigger : MonoBehaviour {
public float trapezeCooldown = 0.5f;
private TrapezePerson trapezePerson;
private GameObject lastTrapeze;
// Use this for initialization
void Start () {
trapezePerson = GetComponentInParent<TrapezePerson>();
......@@ -15,12 +18,27 @@ public class HandsTrigger : MonoBehaviour {
}
void OnTriggerEnter2D(Collider2D collision) {
void OnTriggerStay2D(Collider2D collision) {
if (collision.gameObject.layer == LayerMask.NameToLayer("Key")) {
print("Collision");
print("Collision " + collision.gameObject.name);
if (!trapezePerson.onTrapeze) {
//possibly enable this trapeze after a second
if (!collision.gameObject.Equals(lastTrapeze)) {
lastTrapeze = collision.gameObject;
trapezePerson.AttachToTrapeze(collision.gameObject);
}
}
}
}
private void OnTriggerExit2D(Collider2D collision) {
print("Exit " + collision.gameObject.name);
}
public IEnumerator reactivateTrapeze() {
yield return new WaitForSeconds(trapezeCooldown);
lastTrapeze = null;
StopCoroutine(reactivateTrapeze());
}
}
......@@ -13,6 +13,7 @@ public class TrapezePerson : MonoBehaviour {
private HingeJoint2D hinge;
private Rigidbody2D body;
private HandsTrigger handsTrigger;
[HideInInspector]
public Transform currentPivot;
......@@ -27,6 +28,7 @@ public class TrapezePerson : MonoBehaviour {
currentPivot = midPivot;
hinge = GetComponent<HingeJoint2D>();
body = GetComponent<Rigidbody2D>();
handsTrigger = GetComponentInChildren<HandsTrigger>();
}
......@@ -56,6 +58,7 @@ public class TrapezePerson : MonoBehaviour {
}
//***this has been moved to HandsTrigger.cs***
//void OnTriggerEnter2D(Collider2D collision) {
// if (collision.gameObject.layer == LayerMask.NameToLayer("Key")) {
// print("Collision");
......@@ -80,10 +83,9 @@ public class TrapezePerson : MonoBehaviour {
hinge.enabled = false;
onTrapeze = false;
body.velocity = linearVelocity * exitForce * transform.right;
//currentTrapeze.GetComponent<CapsuleCollider2D>().enabled = false;
//GetComponent<CapsuleCollider2D>().enabled = false;
Time.timeScale = 0.5f;
swingForce *= 2;
body.angularVelocity = 0;
StartCoroutine(handsTrigger.reactivateTrapeze());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment