Hi guys,
I’m trying to pass a character pointer to my spell class, and initially it is storing the pointer fine. I can access methods such as GetActorLocation(),etc. but when I try to access character specific methods, it crashes and says that the pointer is NULL (Mind you it is valid throughout until I access a pointer specific method)
I initially thought it was GC but even after UProperty() the character pointer is null. (This is a networked game)
My character .cpp
spellBar[index]->SetCaster(this);
spellBar[index]->CastSpell();
My Spell.cpp
This debug msg is not firing - CASTER is valid when I initially set it
// A reference to the caster of the spell
UPROPERTY()
MyCharacter* Caster;
void myspell::SetCaster(mycharacter* caster)
{
if (caster)
{
Caster = caster;
if(Caster == NULL){
GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Red, TEXT("Caster is null"));
}
}
Afterwhich I spawn my spell at: CASTER is Valid in this method
GetWorld()->SpawnActor<ASpellSystem>(GetClass(),
GetSpellCaster()->GetActorLocation(),
GetSpellCaster()->GetActorRotation(),
spawnInfo);
The following method I call: CASTER is NULL
GetSpellCaster()->GetDamageModifier_Fire()
Ty