- Home /
Aqueducts connecting.
Hello, we are trying to make a mechanic in our game which acts almost like a 3D water pipe game, the code below that we used did work and then just stopped. Does anyone have any ideas why or how to get it working or any ideas to approach it.
using UnityEngine;
using System.Collections;
public class PM_WoodAqueductTrigger : MonoBehaviour
{
public bool horizontal;
public bool cornerPiece;
public GameObject aqueduct;
void OnTriggerEnter (Collider other)
{
if(cornerPiece == false)
{
if (other.gameObject.tag == "Aqueduct")
{
if (horizontal == true
&& (Vector3.Dot(other.gameObject.transform.forward, Vector3.forward) == 1 || Vector3.Dot(other.gameObject.transform.forward, Vector3.forward) == -1))
{
aqueduct = other.gameObject;
}
else if (horizontal == false
&& (Vector3.Dot(other.gameObject.transform.right, Vector3.forward) == 1 || Vector3.Dot(other.gameObject.transform.right, Vector3.forward) == -1))
{
aqueduct = other.gameObject;
}
}
}
else
{
if (other.gameObject.tag == "Aqueduct2"
&& (Vector3.Dot(other.gameObject.transform.right, Vector3.right) == 1 && Vector3.Dot(other.gameObject.transform.forward, Vector3.forward) == 1))
{
aqueduct = other.gameObject;
}
}
}
void OnTriggerExit(Collider other)
{
if (other.gameObject.tag == "Aqueduct" || other.gameObject.tag == "Aqueduct2")
{
aqueduct = null;
}
}
}
Comment
Add debugs here and there; see that you are still getting the Trigger fire, your Dot values, etc.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Initialising List array for use in a custom Editor 1 Answer
convert c# code for unity return errors 2 Answers
Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer