Skip to content

Instantly share code, notes, and snippets.

@Mazday21
Created January 27, 2023 09:12
Show Gist options
  • Save Mazday21/6568f1bbb81ecccb510807fb2a9abc33 to your computer and use it in GitHub Desktop.
Save Mazday21/6568f1bbb81ecccb510807fb2a9abc33 to your computer and use it in GitHub Desktop.
[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;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment