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"

AI Floating Companion

Hello everyone!

I have a bit of a hefty question, I'm not very good when it comes to AI so this has been stumping me. I have a floating character that follows the main character kind of like Aku Aku from Crash Bandicoot or Sparx from Spyro the Dragon. What I want him to be able to do is to fly with my character and "decide" which side he wants to be on given walls and just whether he wants to be on that side for some reason. When the main character idles, i want him to fly around him and if the main character is idling too long,the companion will start walking on the ground until the main character starts moving again.

Thanks to anyone who can help!

Product Version: UE 4.19
Tags:
more ▼

asked May 03 '18 at 07:57 AM in Blueprint Scripting

avatar image

cometx5
1 1 4

avatar image mightyenigma May 17 '18 at 07:38 PM

I understand what you want the companion to do, but what is your question? What do you need to know in order to be able to make him do that? There's a lot of ways you could do it, so which way are you trying to do that you're stuck on or is not working?

avatar image Nebula Games Inc May 18 '18 at 10:29 PM

AI is all about how you build the "thought process" logic. That is all AI is. Trying to fake "thoughts/decisions" with code. So you have like 2-3 things I can see just from this brief question.

  1. Choose a side to fly on (really the only AI in your question)

  2. Orbit the player during idle movement

  3. Stop orbiting and walk if idle for too long

So for the actual AI part, you would have to decide for your character "what" is he going to decide flight location based on? You mentioned walls...ok so do you want him to seek out walls? Avoid walls etc? I will assume, you want him flying far from walls, so the logic would be something like, run a continuous line trace in an 80 degree arc around the forward vector of the character, if it hits the wall on one side but not the other side set location to hover over the side away from the wall. If later it hits a wall on that side, switch sides. This is how you script AI.

The other 2 issues are a simple branch/boolean set-up not really "AI" as there is no real "decision" to be made for the AI. So you could just get player velocity, if 0 then set AI velocity to 0 and play animation to orbit, or set AI in orbit around the location of the player. If this lasts longer than X seconds set AI to "walk animation". That is the basics of what you would need to code.

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

0 answers: sort voted first
Be the first one to answer this question
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