My arrows seem to be homing to the enemy

Hi! While following the lesson, I find that my arrows are homing in to the enemy, while the instructor’s arrow maintain the same direction once fired.Would anyone know why this would be the case?
homingarrow

here is my lookat script

```public class targetLocator : MonoBehaviour
{
    // Start is called before the first frame update

    [SerializeField] Transform weapon;// field to connect weapon mesh of tower
    Transform target;// variable for LookAt target

    void Start()
    {
        target = FindObjectOfType <EnemyMover>().transform;// setting target to the transform of any gameobject that has the enemymover script
    }

    // Update is called once per frame
    void Update()
    {
        aimWeapon();// aimWeapon method
    }


    void aimWeapon()
    {   
        weapon.LookAt(target); // making the rotation of the weapon mesh look at enemy/targets
    }
}

My ballista prefab

my enemy health script:

:public class EnemyHealth : MonoBehaviour
{

    [SerializeField] int maxHitPoints = 5; // setting the max health of enemy
    [SerializeField] int currentHitpoints = 0; // to store current health of enemy

    // Start is called before the first frame update
    void Start()
    {

        currentHitpoints = maxHitPoints; // set currenthealth to max health at the start of the game

    }

    private void OnParticleCollision(GameObject other)
    {
        processHit(); // call this method on particle collision
    }

    void processHit()
    {
        currentHitpoints--; // -1 from current health

        if(currentHitpoints <= 0) // if current health is less than or equal 0, destroy game object
        {
            Destroy(gameObject);
        }

    }
}

and my particle settings:


Thanks in advance!

1 Like

I haven’t done this course but I think you should not have the particle system as a child of the balista top. This is causing the particle system to rotate along with the top and pulling the arrows along. The other option is to go into the particle system and change simulation space to ‘world’. This will put the arrows in world space and they will not go where the particle system goes.

oh yup that solved it! Thank you so much for the help! :smiley:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms