Hi programming OT, I'm new to programming and Unity and I have a problem that I can't seem to solve.
Let me break it down, please bear with me.
Basically there are 4 switches - Switch 1, Switch 2, Switch 3, Switch 4.
2 Gates - Gate 1 and Gate 2
1 Platform
1 Cage
This is the way the logic is supposed to work and the order.
- You press Switch 1 with Character 1, and Platform 1 on character 2's side, starts moving, but a cage locks Character 1 in. So you switch to Character 2. Character 2 can't get to switch 3 until platform 1 starts moving.
- Character 2 presses switch 3 which opens gate 1. Character 1 is still locked in.
- After switch 3 is pressed, Character 2 goes to switch 4 which opens the cage.
- Then character 2 presses switch 2 which opens gate 2 for character two.
This is the order:
- Switch 1, moves platform
- Switch 3 opens gate 1
- Switch 4 opens cage
- Switch 2 opens gate 2
Code:
public bool SwitchOne;
public bool SwitchTwo;
public bool SwitchThree;
public bool SwitchFour;
public bool SidePlatformOne;
public bool SidePlatformTwo;
public bool UpDownOne;
public GameObject platform;
public GameObject gate;
public GameObject cage;
public bool CageOne;
private Animator anim;
private Animator animone;
private Animator animtwo;
public bool gateone;
public bool gatetwo;
// Use this for initialization
void Start () {
anim = platform.GetComponent<Animator>();
animone = gate.GetComponent<Animator>();
animtwo = cage.GetComponent<Animator>();
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter (Collider other)
{
if (gameObject.tag == "SwitchOne")
{
SwitchOne = true;
SidePlatformTwo = true;
anim.SetTrigger ("SidePlatformTwo");
if((SwitchOne == true) && (SidePlatformTwo == true))
{
CageOne = true;
animtwo.SetTrigger ("GateBlockOne"); //Block's Tarro In and activates her platform
}
}
if(gameObject.tag == "SwitchTwo")
{
SwitchTwo = true;
}
if((SwitchTwo == true) && (gateone == true) && (SwitchThree == true))
{
gatetwo = true;
animone.SetTrigger ("GateTwoLevelTwo");
}
if(gameObject.tag == "SwitchThree")
{
SwitchThree = true;
}
if((SwitchThree == true) && (CageOne == true))
{
gateone = true;
animone.SetTrigger ("GateOneLevelTwo");
}
if(gameObject.tag == "SwitchFour")
{
SwitchFour = true;
}
if((SwitchFour == true) && (SwitchThree == true))
{
CageOne = false;
}
}
}
I've checked everything, added debug log. The code that executes the gate open logic doesn't work. The gate is supposed to open as soon as switch 1 and switch 3 are pressed. But it doesn't work.
I have no idea what to do anymore.
I'm a major noob as i just started 3 months ago and would really realy appreciate the help. Thanks
Never mind, issue has been resolved. Thanks for reading.