Passing a character Pointer is null
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
My Spell.cpp This debug msg is not firing - CASTER is valid when I initially set it
Afterwhich I spawn my spell at: CASTER is Valid in this method
The following method I call: CASTER is NULL
EDIT1: Changed post to better explain my problem.
So I have tried using Ramas Solution to get local PC:
Mind you this works on the server, If I try casting from client 1, the spell spawns at the server owned character.
Also if I run the game on a dedicated server, it flat out crashes on both. Another issue is that if somehow the client runs two copies of the game, then islocallycontrolled PC will cause the 2nd client to spawn spells at the first clients location.
All I need is the caster that spawned the spell (they are on different cpp files, I even tried setting the instigator on my character.cpp and getinstigatorcontroller on myspell.cpp but that didnt work).
So I finally got this working, here is what I had to do:
Right after I initially spawn the spell (to instantiate it and add it to my spell bar), I set the owner like so: (Mind you i had to set it on the server):
Then under my spell.cpp I set the Caster to:
Hope this helps someone out.
Follow this question
Once you sign in you will be able to subscribe for any updates here