Coś tu nie działa jakbym chciał Unity2D C#

1

Ogólnie jestem młody i jestem debilem XD. Próbuje to napisać od dłuższego czasu (Unity2D). Problem jest z "transform.localRotation = Quaternion.Euler(0f, 0f, 0f);", nie zmienia to rotacji, co jest nie tak. Z góry dziękuję.

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

public class LogicGuns : MonoBehaviour
{
    public int toMinus;
    public Transform renkaR;
    public Transform renkaL;
    public bool leftHand = false;
    // Update is called once per frame
    void Update()
    {
        gun_rotation();
    }

    public void gun_rotation()
    {
        Vector3 mouse_position;
        Vector3 gun_position;
        gun_position = transform.position;
        mouse_position = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        float rotation = Mathf.Atan2(mouse_position.y - transform.position.y, mouse_position.x - transform.position.x) * Mathf.Rad2Deg;
        transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, rotation));
        float rotationY = Mathf.Atan2(mouse_position.z - transform.position.z, mouse_position.x - transform.position.x) * Mathf.Rad2Deg;
        if ((rotation > 150  || rotation < -150) && !leftHand)
        {
            leftHand = true;
            transform.SetParent(renkaL);
            transform.localPosition = new Vector3(0, 0, 0);
            transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
        }
        else if ((rotation > 150 || rotation < -150) && leftHand)
        {
            leftHand = false;
            transform.SetParent(renkaR);
            transform.localPosition = new Vector3(0, 0, 0);
            transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
        }
    }
}
1

Pokaż efekt, to lokalna rotacja względem parenta więc jeśli parent jest obrócony to element będzie wskazywał w tym kierunku. Może masz konflikt z innym skryptem.
Poza tym "ręka" się pisze przez "ę"

0

Mam zmienianą rotacje u parenta, jednak nie zmienia, jedyne skrypty jakie mam to na obracanie gracza (gracz jest kulą) i na movement. Wiem że ręka pisze się przez ę, ale użyłem to dla żartu XD

1 użytkowników online, w tym zalogowanych: 0, gości: 1