For the walls to be toggled on and off, their scripts will have to know their current state. Add the following variable to your DynamicWall
class:
public class DynamicWall : MonoBehaviour
{
[SerializeField]
private GameObject wallSection;
public bool isRaised = true;
}
Add a line to the end of MoveSectionDown
to set isRaised
to false
after the wall has been lowered:
public IEnumerator MoveSectionDown() { ... isRaised = false; }
And an opposite line to set it to true
at the end of MoveSectionUp
:
public IEnumerator MoveSectionUp() { ... isRaised = true; }
Now we can add a call to both of these functions from the player using the OrbManager
script. Add a call to a new function called ToggleWall
in the Update
function when the
F
key is pressed. Also, define ToggleWall
as an empty function after the Update
function for now:
void Update() { if(Input.GetKeyDown(KeyCode.F)) { ToggleWall(); } } private void ToggleWall() { }
We're...