Getting a really weird issue. I made a script that rotates an item when hovering over a slot, but the second the game runs, the item gets rotates by -19.081 on the x axis (on top of getting rotated on Y continuously).
This happens on whatever I try to rotate, whether it’s the slot, or the item inside it.
Here’s my script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class ItemSpin : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler {
public Vector3 rotationAxis = new Vector3(0, 1, 0);
public float speed = 1f;
public bool hovered;
void Update () {
if (transform.childCount > 0) {
if (hovered == true) transform.GetChild(0).transform.Rotate(rotationAxis, speed);
else transform.GetChild(0).transform.rotation = Quaternion.Euler(0, 0, 0);
}
}
public void OnPointerEnter(PointerEventData eventData) {
hovered = true;
}
public void OnPointerExit(PointerEventData eventData) {
hovered = false;
}
}
If I leave the script off on a slot before running the game, it doesn’t happen. The second I enable the script, the x rotation is set to -19.081 every single time.