I’m looking what the performance difference is between a function lib and an eventgraph. For context, I’ve created something of an asteroid field around a point. It can spawn any amount of objects within two radius (inner and outer). It moves the orbit of each block at a speed based on the blocks mass and distance from the center vector.
I took the equation and put it in a function lib hoping to make it re-usable. I put the exec line through the function which takes various inputs to output a new vector, which is then moved by a setLocation. For a while i’ve been trying to figure out why this caused a massive slowdown, and tried simplifying the objects, but with no luck.
I went back to using the formula directly on the eventgraph and the fps difference was that of 5 to 30, which is what my macbook sits at without spawning anything.
It looks like that the issue wasn’t draw calls but routing the exec line though the function lib. Is there too much going on here that it would make the function less efficient? I’ve posted the images of the calculation, which determines the new vector based on the inputs.
I’m not sure I understand this, can it be elaborated on?
If I wanted to add a new position to thousands of objects at once, would the best way be to have them on an event tick in the event graph, or to execute a custom event in the eventgraph? Draw call doesn’t seem to affect the issue, as I have attempted this with hidden objects without much improvement.
I don’t know how complex the overall math is in your function, but it does look a little complex from that single snippet if calculating every Tick for many objects, and Blueprint math is the slowest in terms of Blueprint vs C++. Square root and powers are more of the expensive parts in calcuations.
One way to help would be to create a Math Expression Node, which if I remember correctly are 50% better at calculating math than a bunch of nodes since 4.11.
I think what [MENTION=434]BrUnO XaVIeR[/MENTION] is saying that function library calls instantiate a UObject per call (which bring with it a construction cost), whilst this is OK sometimes, doing it every tick for many other actors/bp’s is expensive.
It would appear to me that you might be better of making an AsteroidMoverCompoent and let them all tick away on their own?
would even perhaps use a timeline rather than tick as timelines can be a little quicker for non mission critical updates (as timelines will not necessarily tick every frame but rather then the animation tick fires)
I thought i had actually responded to Aesais, but apparently not. I had tried using a timeline but got no help there either. In the end, the math expression resolved the issue for me, which was a massive improvement. Is that just because the game is calculating an expression without getting values from variables during the process?