void Update()
{
if (active==true)
{
Motion();
Rotate();
}
else
{
}
// Below is set of lines to be displayed once player face them
var fwd = transform.TransformDirection(Vector3.forward);
if (Physics.Raycast(transform.position, fwd, out hit, Reach) && hit.transform.tag == "Bed")
{
interaction.SetActive(true);
if (Input.GetKey(KeyCode.Space))
{
bedLine.SetActive(true);
}
}
else if (Physics.Raycast(transform.position, fwd, out hit, Reach) && hit.transform.tag == "Toilet")
{
interaction.SetActive(true);
if (Input.GetKey(KeyCode.Space))
{
toiletLine.SetActive(true);
}
}
else if (Physics.Raycast(transform.position, fwd, out hit, Reach) && hit.transform.tag == "Speaker")
{
interaction.SetActive(true);
if (Input.GetKey(KeyCode.Space))
{
speakerLine.SetActive(true);
interaction.SetActive(false);
}
}
So, in the second “else if”, I would like for the interaction line to hide and speaker line to show. I tried to include another if statement but it didn’t change anything. Thus, in my game, whenever I go near the object with speaker tag, interaction appears as it should but when i press space bar the interaction line hide and shows resulting in showing both lines.
by the way I’m 2 weeks old with Unity