- Home /
How can I change a scene by the rotation z position?,
Hello Everyone! I'm developing a game that has a key, and when I rotate it, it should open the door. I know that it is a pretty noob question, but I'm really stuck with the syntaxes. Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class GameManager : MonoBehaviour
{
public GameObject gameobject1;
private void update()
{
if (gameobject1 == rotation.position.z)
{
SceneManager.LoadScene("Win");
}
}
}
,
Your question is really unclear. Do you want to load a scene when the rotation of an object is equal to a certain value?
public GameObject gameobject1;
private void Update()
{
if ($$anonymous$$athf.Approximately(gameobject1.transform.localEulerAngles, 90))
{
Scene$$anonymous$$anager.LoadScene("Win");
}
}
Answer by Game_Krator · Jan 01, 2021 at 10:12 PM
Hi @sergio_gn,
I would change (gameobject1 = rotation.position.z) to (gameobject1.transform.rotation.z == ). Put whatever value you want into the "" to check if gameobject1 has rotated. Transform tells Unity that you are going effect a gameObjects rotation, position, or scale. I hope this helps.,Hi @sergio_gn,
I would change (gameobject1 == rotation.position.z) to (gameobject1.transform.rotation.z == ). Put whatever value you want in the "___" to check if "gameobject1" has rotated. Transform tells Unity that you are going to effect a gameObject's position, rotation, or scale. I hope that this helps you.
Your answer
Follow this Question
Related Questions
Something that needs to work but apparently not 0 Answers
Problem when checking a Quaternion Eulerangle axis 1 Answer
Why can't check for rotation 1 Answer
Clamping rotation doesn't work when local axis is different from global 0 Answers
How to Save a UI Image Rotation and Load it When Coming Back from a Different Scene? 1 Answer