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"

Modify AI Move To to rotate and move forward

Hello, I want recreate project on UE4 from Unity. In example project character move to point and rotate to move direction. I want it rotate and move only forward direction and not have problem with physics and not stuck on obstacles. Surf goolge and forum did not bring the results.

alt text

Product Version: UE 4.12
Tags:
aipath.jpg (19.3 kB)
more ▼

asked Jul 29 '16 at 10:42 AM in C++ Programming

avatar image

funkish
41 2 7 7

avatar image mtrebi Jul 29 '16 at 10:48 AM

Just to clarify you don't want the character to walk backwards for example? You want to avoid these kind of thigs and have the character to always walk forward, right?

avatar image funkish Jul 29 '16 at 10:59 AM

Yes I want that the character not move backwards. If player click behind his back, character start rotate and move in face of rotation.

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

4 answers: sort voted first

Simple solution that worked perfectly. From Blueprint Editor

In your Class (first item in your component list, above CapsuleComponent) uncheck "Use Controller Rotation Yaw"

In your CharacterMovement component, check "Orient Rotation to Movement"

Source http://www.dreambotstudios.com/ue4-make-ai-rotate-smoothly-avoid-snapping/

more ▼

answered Feb 11 '19 at 08:27 PM

avatar image

Dayrook
6 1 1

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

Hey,

You have to write your own class UCustomPathFollowingComponent with as parent UPathFollowingComponent and overwrite the function FollowPathSegment(float DeltaTime) to the desired effect. Take a look at this documentation for some details: https://wiki.unrealengine.com/AI_Navigation_in_C%2B%2B,_Customize_Path_Following_Every_Tick

Hope this helps :)
Elias

more ▼

answered Jul 29 '16 at 11:12 AM

avatar image

PasteDog
1.2k 24 18 53

avatar image funkish Jul 29 '16 at 11:23 AM

I saw that topic and based on my experience, I am afraid that the character will be hit into obstacles because character path always calculated for current point to end point. But character movement vector not equal to current path segment vector. Thanks for the quick response, I will try this in any way.

avatar image PasteDog Jul 29 '16 at 11:31 AM

Yes this happens, but only in certain situations,

you could make the AI raycast in front of him and slow his speed down if it hits something, this way he will even react like real humans :)

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

Take a loot at the SetFocus/SetFocalPoint function of AI_Controller. This functions specifies at which object does the character looks (or location) when moving. It has different priorities. I think it is what are you looking for and it is far easy.

more ▼

answered Jul 29 '16 at 12:00 PM

avatar image

mtrebi
348 16 24 27

avatar image funkish Jul 29 '16 at 12:09 PM

Is seting focal point controlling movement direction?

avatar image mtrebi Jul 29 '16 at 12:14 PM

The path that the character follows is the same, the only thing that it changes is the rotation of the characther (the direction that is facing). It has multiple priorities, the character can move to a point always facing that point, even if they are obstacles; or it can focus middle points moving towards the final destination (as humans do).

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

I did it by having my AIController class override UpdateControlRotation to turn slowly towards the next focal point (GetFocalPoint). I then set the character walk/run speed to zero in the character movement settings, and updated the character location manually by something like NewPos = OldPos + (MyMoveSp * DeltaTime * GetActorForwardVector());

As you can imagine, the character didn't stay exactly on the nav path, but it wasn't a big deal in my case. There is no navigation function in Unreal that does exactly what you want (a nav path with tangents that take into account rotation speeds). If you want one, you'd have to write it and hopefully share it with the rest of us :)

In a case such as you showed, Epic would prefer you add a turn around animation that gets the player pointed in the right direction, and then navigate as normal.

more ▼

answered Aug 01 '16 at 08:40 PM

avatar image

rantrod
1.5k 49 47 216

avatar image minnow Dec 12 '17 at 06:50 AM

Hello. I read your post. So you want to say... When AI rotate to move forward, we should use animation?.... Is it right?

If AI is huge size, Epic's Rotation Rate modification method looks very strange... because AI move to opposite direction and footstep is not synced.

(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