Good evening, I wanted to know what the cast was doing. For example, I would like to know what this piece of code does:
This cast checks if the actor hit by a raytrace is a child of class AIInteractable, in case it is it sets the current interactable to the hit actor.
“A cast is a special operator that forces one data type to be converted into another”
In other words you tell programm that specified class (i.e. PlayerController) has all variables, fields and methods of another class (i.e. GameplayController) and should use them instead of their own.
If classes arent compatible cast returns nullptr
Ok but when I cast AGameplayController, when I do GetController() I can modify the current controller class or it is just a copy of the current controller ?
Because in the game I want to modify the current controller class that I’m using, not to copy the current controller class
What do you mean by “modify”?
You can call functions of that class and get/set its variables but they will apply only to the object you casted.
If you need to modify the defaults of that class you need to edit the GameplayController.h file
ok thank you