Event/functions, what's the main difference between them?
They are similar in:
What's the main difference between them? When should we use events, and when should we use functions?
asked Mar 20 '16 at 04:22 AM in Blueprint Scripting
I am not a programmer, but here is my uderstanding of it. Events are allowing you to respond to certain, well, events in your game, like your player hit an enemy, you pressed W on your keyboard, so on. You can set up for example an event "W Pressed" and any nodes (including functions) will be executed after that event node when the player presses W, allowing you to decide what should happen in the game when a certain thing (event) happens.
A common example I hear a lot is to think of functions as car factories. If you want to make one or two cars, you don't build a factory, it doesn't worth it. But if your are planning to make a lot, it might be a good investment. Same for functions, if you want to add A+B in your game only once in your entire code (quite unlikely tho :P) you wouldn't make a function, it is easier to just add them with the ADD node. But imagine if you want to make a calculation more complex and you want to use it all over your game, then you should use functions. You can set input values and output values for functions, meaning you can execute the same code inside them but with different values (A+B example: your function would have an 'A' and a 'B' input and an 'A+B' output and in your function you'd add A to B). This would allow you to get the result of A+B any time, no matter what actually A and B means, the function will run with your desired values. As mentioned above, functions don't allow latent nodes, because they have to return a value immadiately.
I hope it clears up at least a little bit, but take everything I say with considerations, because again, I am not a programmer :)
Functions have output nodes.
Taken from here.
Taken from here.
Follow this question
Once you sign in you will be able to subscribe for any updates here