I have a technical question related to actor movement in a scene targeted for mobile devices.
My current project have a case, where multiple objects have to be spawned and reach different destinations depending on their type.
What is the best practice to simulate the movement for those objects even if they grow on number (using only Blueprints), which will have least impact on the mobile CPU?
Relative Matinee for each object
Local position offset (each frame) for all spawned objects in array
Setting Rotation and adding Velocity based on vector
Other? (In the end - the goal for the object is to reach from point A to B and “die”)
This is one of the core elements in the game – so I need some information on how to do it as optimized as possible.
“Local position offset (each frame) for all spawned objects in array” will have the most as it’s done on every frame, best way to make this faster is to move Tick code to C++
You could use a Timeline within the bp of each actor for a vector lerp. Timelines are a great way to replace Tick anywhere you have it. Timelines allow you to perform various tasks on every frame for its duration, which can be set to any amount of time, or infinite, within the Timeline editor. You can also create graphs within the Timeline editor which can output various float, vector, etc. values and also fire off one-time custom events at specific times within the Timeline. You can play, play from start, stop, reverse, and reverse from start, and have a final event fire when the Timeline is finished. It’s extremely versatile.
The Update output pin is where the action happens, and you’ll see additional output pins depending on the graphs you create within it. The Finish pin is useful for executing some command that wraps up the process.
So in your case, you can do a vector lerp on Update and a Kill on Finish. Do this within the actor’s own bp. You’ll even have a whole lotta control over the lerp because you can create a custom float graph in the Timeline for the lerp’s alpha input.
Basically, if you find yourself wanting to use Tick for anything other than printing string values for testing data, use a Timeline instead. Even with infinite Timelines (just click the Loop box in its editor) you can always stop it whenever you want. You’ll never be wasting processing “waiting” for certain conditions to be met or having a process continuing when it shouldn’t be. You’ll also have much greater control over what’s happening.
We’re making a mobile game that’s launching to iOS and Android in a month, and a big part of optimization was removing all instances of Tick. It noticeably increased performance and allowed us to implement some pretty complex mechanics with no worries.
Yes. I am actually using the Timeline in order to spawn the actors using a .scv that is converted to Float Curve when exported in order to use it in the Timeline as Event Track. The only bad side of Timeline is that you can not change the External Curve Data using pins before starting the Timeline itself.
On other had. I was considering solution for the problem using Particles or Event Projectiles - although they both use velocity in order to apply position offset, and I am not sure how strongly they impact Mobile CPU.
Thanks for the interest in the topic!
To make it simple:
Actors spawned at one location, then taking direction depending on their type to reach destination and get destroyed. If there is a touch event by the Player on that actor during the movement to the appropriate destination - actor is again destroyed and the Player gets pints.
Main problem is the quantity of those actors, and how to implement the movement to be optimized in order to maintain good FPS.
I need to see the performance when having 20 actors moving.
Having this core mechanic solved will allow me to adjust the overall visuals and effects.
Ah I see. I’d still recommend building a bp within the objects themselves, each with a Timeline that moves it to its destination and destroys it. So you’d make a bp class for each type and throw that script in each one. You could easily copy/paste and adjust the destination lerp for each class depending on your needs
Having the BP in the actors also gives you some nice control over any effects that may happen upon destruction
I’d be happy to draft up some bp script for you and post it here, but it’d be helpful if you tried it first and posted it here, so I can more accurately see what you’re going for