Ok, so what I’m trying to do should be simple.
This is a blueprint-only project.
I have a Character class and two derived classes: Player and Enemy.
In Character I have CheckDeath function (implemented) and a Die function (virtual). CheckDeath should call Die from Character blueprint, and then each derived class should handle the call with different implementation each. The problem is, when I call Die from Character class, it doesn’t call Die from subclass, but from itself. I tried making it pure virtual, but then I can’t seem to execute it from Character.
Now I’m trying to use Dispatchers, but feels like I’m overcomplicating something that should be simple.
That means the function Die from Player is not being accessed, even though Player is derived from Character. If I try to make Die pure virtual, I cannot call it from Character blueprint for some reason.
Pure function are functions that should return something since they are evaluated at every call. Pure functions should not have any side effects potentially changing the return value for every call unless if the input parameter is different.
The purity of a function has nothing to do with inheritance, however it is a bit odd that “Char Die” is being called and not “Player Die”. Are you sure that you don’t have a CharacterBP instead of a PlayerBP placed in the Level?
What other options are not default in the class and functions?
Perhaps try and recreate the behavior in two new Blueprint classes and see if the problem persists.
Glad you solved it, it is a classic mistake we all make making wrong assumptions as to where the issue is which results in tunnel vision. Sometimes you just need to take a step back and go through everything.
The main difference between pure and impure functions is that impure functions have to have their execution pin called while pure functions don’t have execution pins and is called once for every node it is connected to.