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?
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!