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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

4 directional movement for enemy

So I am making a top down style hack n slash and I have the player moving in only 4 directions(Up, down, left and down). What I want now is for the enemies to move in a 4 directional way as well. Honestly not sure where to start with this so any help would be appreciated :).

Thanks in advance! :D

Product Version: Not Selected
Tags:
more ▼

asked Nov 17 '15 at 01:54 AM in Blueprint Scripting

avatar image

ThatGuyMiniB
38 20 17 21

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

2 answers: sort voted first

You have only 3 (reasonable) ways:

  • Implement custom CharacterMovementComponent and make sure externally requested movement vectors get axis-aligned

  • Implement custom PathFollowingComponent and axis-align movement vectors passed down to AI's movement component

  • Implement grid-based NavigationData along with pathfinder that will generate grid-paths. If you properly generate paths the rest will just work.

Those are the proper ways. I bet there's a trick solution for it as well, but I don't do tricks ;)

Cheers,

--mieszko

more ▼

answered Nov 17 '15 at 02:50 AM

avatar image

MieszkoZ STAFF
7.3k 223 57 412

avatar image ThatGuyMiniB Nov 17 '15 at 03:07 AM

Those all sound super complicated XD how would I go about starting the setup in blueprint? I have tried to find stuff on custom character movement component in blueprints but most of the stuff is c++.

avatar image MieszkoZ STAFF Nov 17 '15 at 03:48 AM

The only way I can imagine getting the result you seek in BP is by micro-controlling AI's movement. I mean telling AI where to go in a straight line and once it gets there tell it again, and again, and so forth.

You should be able to get a "path object" in BP, that could guide this kind of micro-managed movement.

I'm sorry but we don't support this kind of movement for AI out of the box :/

avatar image ThatGuyMiniB Nov 17 '15 at 03:52 AM

So I would need to use C++ then in order to achieve what I am looking for?

avatar image MieszkoZ STAFF Nov 17 '15 at 03:55 AM

No, I said I can imagine doing this in BP. But either way you'll need to put some work in, there's no single switch you can flip to get this behavior.

avatar image ThatGuyMiniB Nov 17 '15 at 04:00 AM

I'm willing to put in the work just trying to look where to get started. I'll research what you suggested some more and will come back if I have questions.

Thank you for the help!

avatar image ThatGuyMiniB Nov 17 '15 at 06:51 AM

So I have been researching but am having trouble making sense of any of the 3 ways you said I could possibly achieve this.

avatar image Justin.Dooley Nov 17 '15 at 09:55 PM

As a super simple limiter, when you tell the AI to move, make sure that either the X or Y value on the move to is equal to your current location. That would make sure you are only moving either vertically or horizontally.

avatar image ThatGuyMiniB Nov 18 '15 at 12:09 AM

So this is what I have for AI so far. Idk if I am doing this correctly or not, but right now it will move to the play when the player passes over a trigger. Should the next step I do be to get player location and then do a break vector and then set actor location to the player?

alt text

ai.png (309.5 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Little update. I now have ai movement that can move randomly and then chase the player in vision but what I want to achieve now is to put points on the map and make the ai randomly move to those points but only use one axis at a time. So basically no moving diagonally.

more ▼

answered Nov 19 '15 at 09:46 AM

avatar image

ThatGuyMiniB
38 20 17 21

(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