© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
54 replies
Martiiic

✅ HAVING TROUBLE CALLING A FUNCTION

So I've made an ingame saving system like the one in hollowknight but Im having trouble with something. My enemies despawn when you enter and that's alright until you want to get out the save point, I want the enemies to respawn after exiting the save point but it doesnt. Sorry for bad englsh.

CLASS1 Enemic:

public void PlayerEnterAltar()
{
Enemic[] enemies = FindObjectsOfType<Enemic>();
foreach (Enemic enemy in enemies)
{
enemy.MortSLS = false;
enemy.IsDead = false;
enemy.CurrentMoveSpeed = enemy.moveSpeed; // Guarda la velocitat actual
enemy.moveSpeed = 0f;
enemy.gameObject.SetActive(false);
}
}




public void PlayerExitAltar ()
{
Debug.Log("Enemics tornen a apareixer");
Enemic[] enemies = FindObjectsOfType<Enemic>();
foreach (Enemic enemy in enemies)
{
Debug.Log("Enemics tornen a apareixer");
enemy.gameObject.SetActive(true);
enemy.MortSLS = false;
enemy.currentHealth = enemy.maxHealth;
enemy.moveSpeed = enemy.CurrentMoveSpeed;
}
}

CLASS 2 Player (where PlayerExitAltar and PlayerEnterAltar are called FILE)
message.txt15.37KB
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

❔ Having trouble with a player swap function
C#CC# / help
4y ago
Calling a function from a string.
C#CC# / help
4y ago
Blazor: calling a function on submit
C#CC# / help
2y ago