Hello, hope you are having a good day. I am making a little horror game of mine, and for it I decided to have an inventory system. It is working, however when I try to set the rotation, it acts very weirdly by being in a completely different rotation even if I did a different rotation. Here is the inventory:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Inventory : MonoBehaviour
{
public int startingIndex = 0;
public int maxCount = 2;
public List<Image> img;
public List<GameObject> inventory;
public Vector3 handPosition;
public Quaternion handRoation;
public GameObject player;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
for (int i = 0; i < inventory.Count; i++)
{
if (i == startingIndex)
{
inventory[i].SetActive(true);
}
else
{
inventory[i].SetActive(false);
}
}
if (Input.GetAxis("Mouse ScrollWheel") > 0)
{
if (startingIndex < inventory.Count)
{
startingIndex++;
}
else
{
startingIndex = 0;
}
}
if (Input.GetAxis("Mouse ScrollWheel") < 0)
{
if (startingIndex > 0)
{
startingIndex--;
}
else
{
startingIndex = inventory.Count;
}
}
}
public void Pickup(GameObject gmj)
{
if (inventory.Count < 4 && !gmj.GetComponent<item>().isImage)
{
inventory.Add(gmj);
int idx = inventory.IndexOf(gmj);
img[idx].sprite = gmj.GetComponent<item>().img;
gmj.transform.parent = player.transform;
gmj.transform.localPosition = handPosition;
gmj.transform.rotation = new Quaternion(0,0,90,0);
}
else
{
return;
}
}
}
I can provide further screenshots if ya’ll are confused