vendredi 5 novembre 2021

Seeing if rotation has chaned with if statement

I am trying to see if my prefabs has chanced rotation in anyway but this ain't working any one know how i have to do this I am calling this script in other script and that's working the Debug.Log Shows up

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Pawn : MonoBehaviour
{
    private GameObject pawnName;

    public Transform tf;


    [SerializeField]
    float eulerAngX;
    [SerializeField]
    float eulerAngY;
    [SerializeField]
    float eulerAngZ;



    public void Start()
    {
        tf = GetComponent<Transform>();
    }

    public void OnTriggerEnter(Collider other)
    {
        
    }

    public void PawnHasFallen()
    {
        eulerAngX = transform.localEulerAngles.x;
        eulerAngY = transform.localEulerAngles.y;
        eulerAngZ = transform.localEulerAngles.z;
        Debug.Log("Calling this script");

        if (eulerAngX < 0 || eulerAngX > 0 || eulerAngY < 0 && eulerAngY > 0 || eulerAngZ > 0 || eulerAngZ < 0)
        {
            Debug.Log(pawnName + "Has Fallen");
        }
       
    }

}

Aucun commentaire:

Enregistrer un commentaire