I want to make a ball move following the trajectory i made.
I have calculated each position that the ball will stay in the trajectory.
I made a delay before i change the location of the ball, in order to observe the movement of the ball.
But even I set the value of delay very small, even for 0. The span of the delay is almost 0.1s，really larger than the duration that i have set.
So the wrong effect will be: the bullet moves really slow，much slower than I want it be. Thats the first question，Why ?
And the second question is also find delay 0 is different from no delay.
I’m eager for help. Any guidance will be much appeciated!
Small delays are impossible, CPU executes code in sequence and it can’t do 2 things in same time or else you executing 2 threads in 2 different cores and there no guarranty that those 2 threads will be in different cores or else OS will be requested to do so, this is only case where you have true parallel execution. Multitasking OSes only gives you illusion of parallel execution, but in reality single CPU (each Core is practically separate CPU) can’t do 2 things in same time (modern CPUs do some things in parallel , but it only makes code execution faster by doing few CPU instructions iin sequence in same time), OS simply shares CPU time with other processes and there threads that why it looks like it can do more things then one in same time. Because of this sequential nature of CPU, in world of programing there is no sense of time, you can only look on what time is it in some point of code and react to it in specific way.
So delay created by Delay node is also just a illusion of delay. Engine works in frame by frame loop, it check most of the time related stuff on every frame, for example it check if there some “Delay” node waiting, if in current frame time passed to execute the rest of the code, if it is it executes, ofcorse it is more not that simple it use more time aligment. If you gonna give small delay, engine won’t have time to even reach delay node check process, it will be waiting until next check. 0 delay either executed imidietly, or it will wait one frame in delay system, either way it is more pointless then executing stuff right away.
If you want to check state of a object all the time, use Tick event which executes on every frame. Everything updates on every frame not in between (you might find some rare cases, engine updates gameplay states exclusively per frame), so it poitless to even execute gameplay code bettween frame, thats why Tick event is most optimal solution. Tick event gives you Delta Time which is estimated time passes since last frame allowing you to align your calculations to time instead to frame count (which would make fps effect speed of object for example). You also need to remeber that blueprints are slower then native code compiled from C++. so if you gonna have a lot of stuff in tick CPU won’t have time to execute everything before next frame should apper on the screen, which as you may guess result in reduction of fps. So if it’s possible it is recommended ot use C++ if you plan some heavy computations on tick event or use blueprint nativisation.
Thank you very much! i have just completed the changes in the event tick,it works, really thank you!