Alternative to casting every possible actor
Hi, I am looking for an alternative to casting to every possible actor. For example, in my scenario I have a character that can move freely. I have cover actor when character collides with, gets in to cover, I have collectibles when collided can be obtained automatically. And the list goes on. So here is my question. When collision happens, is casting to each possible act is a good way to maintain this or is there a better design for this?
Here is the example I can show.
Thanks in advance.
asked Jan 10 '19 at 12:32 PM in Blueprint Scripting
Interface. Set a Blueprint Interface with 1 function, like I_Collided or whatever. Set all your actors to implement that interface, and use the I_Collided event to drive your functions. In the Character BP, send an I_Collided message to the actor the Characted has collided with.
answered Jan 10 '19 at 12:45 PM
you still can use casting but in a simpler way.
Make generic Parent class that "vehicle", "collectible" and "cover_exmple" are derived from it, in the Generic_Parent class have the main generic functionality that is common between all.
Have a function in the parent class that returns a class type, which says what is the actual type of the parent class instance. then the followings will be your steps
answered Jan 10 '19 at 12:57 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here