Hiya.
I’ve been working on a slight puzzle as I’m slightly new with coding. I’m trying to make a puzzle game at the moment, but having the same rotation number works, BUT. I’m trying to make the script work with different numbers.
Take a look,
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SewerPuzzle : MonoBehaviour
{
public GameObject Spotlight, Spotlight1, Spotlight2;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Spotlight.transform.rotation.eulerAngles.z == 180 &
Spotlight1.transform.rotation.eulerAngles.z == 180 &
Spotlight2.transform.rotation.eulerAngles.z == 180)
{
Debug.Log("yes");
}
}
}
As said, this works PERFECTLY. But after I change the numbers, differently. It doesn’t seem to work afterwards. Here’s an example.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SewerPuzzle : MonoBehaviour
{
public GameObject Spotlight, Spotlight1, Spotlight2;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Spotlight.transform.rotation.eulerAngles.z == 120 &
Spotlight1.transform.rotation.eulerAngles.z == 300 &
Spotlight2.transform.rotation.eulerAngles.z == 20)
{
Debug.Log("yes");
}
}
}
I’m still flustered on this, as I need the 3 to be completely different, and trigger something if all 3 are that rotations, I tried the difference of & (and) &&.
Thanks for the help if so!