Another way to access one scene from another scene is to give the scene a class name.
This makes the scene globally accessible along with all of its variables and methods.
A class is a blueprint or template for creating objects, defining a set of attributes (data) and methods (functions) that the objects will have.
Once we have saved a scene, we may reuse it in other scenes by creating new instances of it. In fact, we have created a new unnamed class. To give our class a name, we may use the ‘class_name’ keyword to register it as a new type in Godot’s editor.
Give the Enemy script a class name
So we can access it from other scenes
In order for the Enemy to take damage
We should set the maximum hit points
Create a set variable to update
the max_hitpoints and to trigger
the enemy into a provoked state
If the hitpoints fall to 0 destroy this enemy
hitpoints are set to whatever the maximum hitpoints are when the enemy is first loaded from then on whenever there is a change to enemy health the set function is run to update things
Open the HitScanWeapon script
Add an export variable to represent weapon damage
check if the collider is the Enemy class
if it is reduce the hitpoints by weapon damage