Hi all, so I’m fairly new to c++ and ue4 and I have used casting multiple times in overlap events and using it to get the main player character. However, I’m rather stumped because I have these two classes which I would like to communicate via casting but I have no way to get them to communicate as I can’t access them for example using a GameplayStatics function or GetControlledPawn(). Maybe it’s that I don’t understand the concept of casting fully as I can’t seem to figure out a way to do this. If anyone could help me out, it would be much appreciated. Thank you
Your problem is probably not casting, but how to access the second class in the first class. You should elaborate or provide some code.
Yeah, casting isn’t a method to communicate between two object types. It’s a way to change one object type into another – like if you have a custom class Foo that inherits from AActor – If you have a pointer to an AActor that you know is also a Foo, you can cast the AActor to Foo to get at its Foo functionality. scratscrat is correct – your issue is access between two different classes. Your solution can probably be achieved in a couple different ways, but providing more information as to what you’re trying to accomplish will help in figuring out the best way to go about it.