public void Init(BaseCharacterMono caster, Damage damage, BaseCharacterMono target, Vector3 targetPos = default(Vector3)) { Caster = caster.Character; CasterMono = caster; _damage = damage; Target = target; Direction = targetPos; _baseHeight = transform.localScale.y + 0.2f; transform.position = transform.position + new Vector3(0, _baseHeight, 0); var spawnPosition = caster.GetComponentInChildren <ProjectileSpawnPosition>(); if (spawnPosition != null) { transform.position = spawnPosition.transform.position; } if (Direction != Vector3.zero) { transform.LookAt(Direction); } else if (target != null) { transform.LookAt(target.transform.position); } else { Destroy(gameObject); return; } //todo: hi if (caster.Character.CharacterType == CharacterType.Player) { var player = (PlayerCharacter)caster.Character; var classDef = Rm_RPGHandler.Instance.Player.CharacterDefinitions.First(c => c.ID == player.PlayerCharacterID); ProjectileSpeed = classDef.ProjectileSpeed; ImpactPrefabPath = classDef.AutoAttackImpactPrefabPath; ImpactSound = classDef.AutoAttackImpactSound; TravelSound = classDef.ProjectileTravelSound; var weapon = player.Equipment.EquippedWeapon as Weapon; weapon = weapon ?? player.Equipment.EquippedOffHand as Weapon; if (weapon != null) { var wepDef = Rm_RPGHandler.Instance.Items.WeaponTypes.First(w => w.ID == weapon.WeaponTypeID); ProjectileSpeed = wepDef.ProjectileSpeed; ImpactPrefabPath = wepDef.AutoAttackImpactPrefabPath; ImpactSound = wepDef.AutoAttackImpactSound; TravelSound = wepDef.ProjectileTravelSound; } } else { var cc = (CombatCharacter)caster.Character; ProjectileSpeed = cc.ProjectileSpeed; ImpactPrefabPath = cc.AutoAttackImpactPrefabPath; ImpactSound = cc.AutoAttackImpactSound; TravelSound = cc.ProjectileTravelSound; } if (TravelSound.Audio != null) { SoundGameObject = AudioPlayer.Instance.Play(TravelSound.Audio, AudioType.SoundFX, transform.position, transform); SoundGameObject.GetComponent <AudioSource>().loop = true; SoundGameObject.AddComponent <DestroyHelper>().Init(DestroyCondition.GameObjectIsNull, gameObject); } Destroy(gameObject, 5.0f); _initialised = true; }