I'm currently very new to Godot and I'm figuring out how to implement basic FPS mechanics. So far I've added:
- a controller (moving, jumping and dashing)
- a simple shooting mechanic, where a raycast checks whether the collider is an enemy object or not
- enemy AI which currently just chases the player.
I added a quick animation, titled "enemy_hit", to show that the enemy object has been hit. It consists of changing the material (albedo) to a more intense shade of red for 1/3 of a second. The problem is that every instance of that object plays this animation simultaneously.
In my enemy scene, called "EnemyTarget", I have a function which runs whenever there's a collision between the object and the player's raycast when firing:
if (health == 0):
The health_drained signal is sent to the main scene. I store the enemy nodes in an array (and I know it's probably not optimal, but it's a temporary solution), so when the signal is emitted, I search for the index of the target node and play the animation afterwards. the code is as follows:
var enIndex = enemies.find(enemyObj, 0)
So... any ideas? I have no idea how to make it so that only one instance plays the animation. Maybe it has to do something with the material?