private void SetupRightHand() { RightHandIdentifier rightHandIdentifier = rightHand.GetComponent <RightHandIdentifier>(); if (rightHandIdentifier == null) { rightHand.gameObject.AddComponent <RightHandIdentifier>(); } }
void SpawnWeapon() { WeaponItem weaponToSpawn = null; if (useDefaultWeapon == true) { weaponToSpawn = troopData.defaultWeaponToSpawnWith; } else { weaponToSpawn = weaponToSpawnWith; } bool HasExistingWeapon = CheckForExistingWeapon(); if (HasExistingWeapon == true) { bool isSameType = CheckIfExistingWeaponIsSameType(weaponToSpawn); if (isSameType == true) { return; } else { WeaponItemRuntime currentWeapon = GetComponentInChildren <WeaponItemRuntime>(); if (currentWeapon != null) { if (currentWeapon.weaponItemData != weaponToSpawn) { DestroyImmediate(currentWeapon.gameObject); currentWeapon = null; } } } } GameObject createdGEO = PrefabUtility.InstantiatePrefab(weaponToSpawn.weaponPrefab) as GameObject; RightHandIdentifier rightHand = GetComponentInChildren <RightHandIdentifier>(); // Debug.Log(rightHand); // Debug.Log(createdGEO); createdGEO.transform.parent = rightHand.transform; createdGEO.transform.localPosition = Vector3.zero; createdGEO.transform.localRotation = Quaternion.identity; }