Skip to content

Instantly share code, notes, and snippets.

@Mazday21
Created January 27, 2023 09:12
Show Gist options
  • Select an option

  • Save Mazday21/6568f1bbb81ecccb510807fb2a9abc33 to your computer and use it in GitHub Desktop.

Select an option

Save Mazday21/6568f1bbb81ecccb510807fb2a9abc33 to your computer and use it in GitHub Desktop.

Revisions

  1. Mazday21 created this gist Jan 27, 2023.
    25 changes: 25 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    [SerializeField] private Weapon[] _weapons;

    private Transform[] _transformsWeapon;

    private void Start()
    {
    for(int i = 0; i < _weapons.Length; i++)
    {
    _transformsWeapon[i] = _weapons[i].transform;
    }
    }

    public void ReturnGameObject(GameObject gameObject)
    {
    Weapon weapon = gameObject.GetComponent<Weapon>();

    for(int i = 0; i < _weapons.Length; i++)
    {
    if (_weapons[i] == weapon)
    {
    gameObject.transform.rotation = _transformsWeapon[i].rotation;
    break;
    }
    }
    }