x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to delay a very fast time

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. alt text 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!

Product Version: UE 4.14
Tags:
question04.png (186.5 kB)
more ▼

asked Feb 02 '17 at 03:36 PM in Blueprint Scripting

avatar image

Sharkafuc
35 4 5 6

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Feb 02 '17 at 04:19 PM

avatar image

Shadowriver
35.2k 921 166 1098

avatar image Sharkafuc Feb 04 '17 at 05:57 AM

Thank you very much! i have just completed the changes in the event tick,it works, really thank you!

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question