Please help. any advice is appreciated.
I created a magic fireball throwing enemy, when there is only one enemy the fireball starts at the my_spell_source transform as expected… however, when I have more than one, all fireballs start at the source of a single enemy. I assume that each iteration of the enemy object is using the my_spell_source of the first enemy in the scene… but I’m not sure what is a better way to give each its own origin.
Is there a way to only a.Find an object by name that is ONLY inside of each object ?
here is a snippet of the code.
// *** START ***
void Start () {
target = GameObject.Find ("Player").transform;
my_player = GameObject.Find ("Player");
my_player_script = my_player.GetComponent <GUI_HUD> ();
// spell source
my_spell_source = GameObject.Find ("enemy_spell_source");
public void magic_attack()
{
magic_interval = 6.0f;
magic_next = Time.time + magic_interval;
// anim
//int magic_hit_dmg = 21;
GameObject fireball_clone;
fireball_clone = Instantiate(fireball_prefab_source, my_spell_source.transform.position, my_spell_source.transform.rotation) as GameObject;
//_clone = Instantiate(source, position, rotation);
Vector3 shoot_angle = my_spell_source.transform.forward;
fireball_clone.rigidbody.velocity = shoot_angle * 100 * Time.deltaTime;
}