// Start is called before the first frame update void Start() { spawnWeapon = Instantiate(WeaponToSpawn, weaponSocketLocation); if (spawnWeapon) { EquippedWeapon = spawnWeapon.GetComponent <WeaponComponent>(); if (EquippedWeapon) { EquippedWeapon.Initialize(this, PlayerCrosshair); GripIKLocation = EquippedWeapon.GripLocation; PlayerAnimator.SetInteger(WeaponTypeHash, (int)EquippedWeapon.WeaponInformation.WeaponType); } } PlayerEvent.Invoke_OnWeaponEquipped(EquippedWeapon); }
void Start() { // spawn weapon and attach to player's weapon socket GameObject spawnedweapon = Instantiate( WeapontoSpawn, WeaponSocketLocation.position, WeaponSocketLocation.rotation, WeaponSocketLocation ); if (!spawnedweapon) { return; } // set equipped weapon to spwaned weapon EquippedWeapon = spawnedweapon.GetComponent <WeaponComponent>(); if (!EquippedWeapon) { return; } print(EquippedWeapon); // initialize weapon EquippedWeapon.Initialize(this, PCrosshair); PlayerEvent.Invoke_OnWeaponEquipped(EquippedWeapon); // set grip inverse kinematic location GripIKLocation = EquippedWeapon.GripLocation; // set weapon type for animator PAnimator.SetInteger(WeaponTypeHash, (int)EquippedWeapon.WeaponInformation.WeaponType); // UpdateAmmoIndicator(); // if (spawnedweapon) // { // // set spawned weapon's parent to player's weapon socket // spawnedweapon.transform.parent = WeaponSocketLocation; // print("Weaponspawned"); // } }
public void OnWeaponSwap2(InputValue button) { Debug.Log("Working"); Destroy(spawnWeapon); spawnWeapon = null; spawnWeapon = Instantiate(Weapon2, weaponSocketLocation); if (spawnWeapon) { EquippedWeapon = spawnWeapon.GetComponent <WeaponComponent>(); if (EquippedWeapon) { EquippedWeapon.Initialize(this, PlayerCrosshair); GripIKLocation = EquippedWeapon.GripLocation; PlayerAnimator.SetInteger(WeaponTypeHash, (int)EquippedWeapon.WeaponInformation.WeaponType); } } PlayerEvent.Invoke_OnWeaponEquipped(EquippedWeapon); }