Okay so I feel like I’m asking probably a dumb question but here goes. I cannot for the life of me cast reliably. I’ve scoured documentation and forums trying to figure out how to reliably determine the reference a CastTo needs to function properly but I have yet to find a comprehensive list of any sort. I’ve been able to fix most of my casting fails, but its always been through brute forcing every possible node into the pin on my cast node, or happening to find someone else with the EXACT same problem. I’m just hoping someone here could take the to enlighten me because its getting incredibly frustrating.
Hi
How are you casting and what are you casting for?
Can you put an example or 2 with when it works, Show some casting that failed at first and what did you do to fix it.
Many people cast incorrectly for the wrong reasons, cast for a yes or no, and try to get X Var. Some the other ways around.
Cheers
To cast to something I’m just using the CastTo(X) blueprint node in the event graph. Usually I’m casting so that I can get access to a variable stored in the blueprint that I’m casting to, or I’m casting as a check to make sure that whatever I’m trying to do only affects the casted . The only blueprints that I’ve successfully been able to cast between are my AnimBP and my CharacterBP. Anything else is crazy hit and miss. For example I’ve been trying to Cast to this CrateBP I set up, its literally just a cube with some physics turned on, but nothing that I could think of functioned as the proper reference
I assume that you have an instance of your CrateBP in the level?
You should be able to get all objects in your level by type
This might be useful
https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/FindingActors/Blueprints/index.html
You should check that an is valid before attempting to cast it … there is an “Is Valid” execution node that will exclude objects that are not initialized for example
The main thing to consider before casting an is how are you going to get that in the first place that you want to cast
Thank you so much, you sir are a saint! You were right , it had to do with me not checking to make sure that it was valid before attempting to cast