Call function on undefined blueprint?
I am trying to make a system where, using a line tracer, I can make the player interact with objects, however, it seems that the only way to call a function on an object is by dragging in a reference to the exact object, therefore meaning it is impossible to call a function on an actor that is found via a line trace? If anyone has a method for this, it would be most useful :)
The easiest way to do this is with a 'cast' node. There is an example in this little tutorial I did: https://www.youtube.com/watch?v=q_9QKzLK-sU
You are basically finding out if a thing is of a particular type, so you can operate on it as that type if so.
A more advanced workflow is something called Blueprint Interfaces: https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Types/Interface/index.html
You could create a 'Interaction' interface and add a function to it called 'OnInteract'. Then add that interface to any Blueprint that you want to interact with (under Blueprint Props), and you will be able to add the OnInteract event node in its event graph. Then in your pawn, when you do your trace, try using the OnInteract 'message' node on the thing you hit. If it implements that interface, the event will fire in it. If it doesn't, nothing will happen. We will certainly have a tutorial for this soon, it's easier to see in practice, but for now casting will certainly get the job done!
The answer is interfaces.
Create a blueprint interface where you define the functions you need, then implement it in the actors you need to be able to call them on.
Then you can call the functions from other blueprints.
answered Apr 06 '14 at 06:00 PM
The easiest way is to use game tags. Your blueprint can set a tag on the Hit Actor, so that in case that actor has a blueprint that checks if it's been tagged in a specific way it will perform some action accordingly.
answered Mar 23 '14 at 01:20 PM
Pino of DFT Games
Follow this question
Once you sign in you will be able to subscribe for any updates here