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"

Quick Timer By Function?

Hi guys,

I have a quick question about Timer by Function. Basically I have a top down character and when my character is attacking I want him to be rotated towards wherever my cursor is on the screen. I have this set up fine at the moment by having a Timer By Function with the function running the script every 0.01 seconds to change the character's rotation towards the cursor.

Now in previous experience the Timer by Function/Event tends to act a little funny below 0.2 seconds once compiled (works fine in editor). So my question is, what would be a better way to have this script running? It needs to be essentially every frame, but I am very reluctant to use an event tick on something that only needs to be called during specific moments.

Thanks in advance,


Product Version: UE 4.20
more ▼

asked Sep 17 '18 at 09:19 PM in Blueprint Scripting

avatar image

46 3 1 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

For something that responsive I'd definitely run this on Tick. You can always Gate it:

alt text

capture.png (30.5 kB)
more ▼

answered Sep 17 '18 at 10:21 PM

avatar image

15.2k 77 25 62

avatar image Tisreece Sep 18 '18 at 12:29 AM

How costly is this? For example, if I had multiple gates like this to do responsive mechanics when called for, would it effect performance much, even if most of them were closed at any given time?

Edit: Also, thank you for the response :)

avatar image Everynone Sep 18 '18 at 09:22 AM

It is not costly and it will not affect performance. There's nothing wrong with Tick. You see folks demonise its use, and rightly so but it relates to using it when not necessary.

  • if you need for something to happen once, do not put in tick

  • if you need to cast during tick, see if you get away with an event-based cast and use a direct reference or another form of blueprint communications

  • if you need something to happen in x amount of time, use a Timeline instead of Tick

You can use a switch instead of a gate if you need several paths of execution; you can switch on enumerators, indexes, even strings. In this case, only one output will be active:

alt text

capture.png (38.6 kB)
avatar image Tisreece Sep 18 '18 at 06:19 PM

Yes I have tried switch on another part of my script before, but instead I used an integer input.

I'm assuming I would need a sequence node to do multiple switches/gates for the same tick?

avatar image Everynone Sep 18 '18 at 07:32 PM

Yup, cascading branches and so on. You can also disable tick or slow it down - Tick Interval in the class defaults. There are many ways of handling flow control.

You can add/remove components to/from actors, those components can have their own tick and methods. You can have a component that causes the character to bleed (it will tick once per second handle all blood related mechanics and visuals).

A component like this can be given to anything that can bleed from now. A chunk of reusable behaviour with its own tick so you do not muddle the main actor.

avatar image Tisreece Sep 18 '18 at 08:16 PM

Oh wow thanks for the information, you've been really helpful. Next time I have unreal open I will definitely have a look into these other tick methods.

Thanks again :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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