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"

Get AI current direction?

Hey, fairly new with Unreal here; I'm making a 2D NPC that moves "ping/ponging" throughout 3 control points using InterpToMovement.

I'm able to change my controllable character animation through inputs responses, but I can't make the NPC change his animation because there is no input.

Q: Is there a node/way to get the NPC current location/direction? So that way, for example, if he is moving down in the Z axis, then its shifts to "MoveDown" flipbook?

Thanks, hope I communicated well :)

Product Version: UE 4.20
Tags:
more ▼

asked Sep 18 '18 at 11:38 PM in Blueprint Scripting

avatar image

Dazhúm
15 1 3

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

1 answer: sort voted first

If I understood right maybe you are looking for this node? If yes then connect the AI to the target and you can get the x,y,z values depending on if you need location or rotation. alt text

more ▼

answered Sep 19 '18 at 12:54 AM

avatar image

VortXGaming
255 5 5 12

avatar image HarryHighDef Sep 19 '18 at 10:56 AM

There is also get actor velocity, which may be more useful for your 2D setup..

avatar image Dazhúm Sep 19 '18 at 12:39 PM

@HarryHighDef It works better indeed!

@VortXGaming Thanks! That solved half of it, is there a way to attach these two branches to the event tick? (using a Sequence node or calling one of the branches in a construction script doesn´t seem to work)

![alt text][1]

npcbp2.png (180.9 kB)
npcbp2.png (180.9 kB)
avatar image VortXGaming Sep 19 '18 at 10:19 PM

Hello again . I suggest using Custom events ,one for each branch and then connect them to event tick .Otherwise you can check about the multigate node .Maybe this will work out for you. However I believe the sequence node should work so it is probably something else that is wrong. Good luck!

avatar image Dazhúm Sep 20 '18 at 02:18 AM

Hey . I can only link one of those custom events to the event tick, how do you connect both?. Checked multigate node, but as the sequence node, it fires them in order; although, since multigate node has a Loop boolean, it would be nice to change how "fast" does it switches from Out 0 to Out 1, but couldn't find a way since I can only make it either loop or not loop, not change the way it loops.

Thanks a lot!

avatar image VortXGaming Sep 20 '18 at 12:08 PM

Hey. I wanted to say to connect the custom events serially. But anyway some usefull information . Let's say you use a sequence node connected to an event tick node and in case 0 you are using a delay node and in case 1 you do not use a delay . The case 1 is not going to wait for the delay within case 0 to run its body. Although the case 0 is not going to be executed per frame multiple time but every time the delay duration is passed. (If you add delay node at the beggining just after case 0). Check this link for more info about this. https://answers.unrealengine.com/questions/715705/why-use-sequence-node.html

Now about the multigate node ,you can control how fast a variable value is changing over time by using a timeline (right click on blueprint and go to the bottom add timeline). Maybe you will be able to control that loop by a value with a timeline but I have never tried this before. I suggest using multigate not after event tick but after event begin play and then control the loop with timeline or delay.

To sum up I personally use in a project a sequence node in my main character after event tick and one after the event begin play nodes. I have like 7-8 cases to each one and they all working like a charm. (I use them to check various boolean variables so events are triggered in different times ) . I never had problem with the time that they are executed . So I have to conclude that the reason why you can not get the result you want is not the execution flow but some other mistake in your script.

avatar image Dazhúm Sep 20 '18 at 02:30 PM

Yep, there probably is a mistake/lazy logic that I'll try to make clearer. However, in this case, adding delay nodes to the sequence node and changing their duration worked fine.

Thanks for the patience and the well explained info, VortX :)

avatar image VortXGaming Sep 20 '18 at 02:37 PM

You are welcome ! Have a nice day!

(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