Search Unity

Question Best way to make a hovering companion?

Discussion in 'Editor & General Support' started by karsten-heim, Jan 13, 2023.

  1. karsten-heim

    karsten-heim

    Joined:
    May 16, 2022
    Posts:
    63
    My game so far is based around getting an upgradeable flying toaster companion home by transcending different realities, but I am missing half of the game right now which is the toaster itself. I intend to have it follow around the player, and be able to follow the player even in confined spaces (such as the cave system i made). I suppose a potential solution to this would be to make the mesh taller and use it as a navmeshagent to follow the player, or have a whole layer in the collision matrix that only the toaster can collide with, and the layer would be higher than the ground to give the appearance of flying, but I want it to be sort of lifelike, and going places other than the player, like being able to aid in boss fights I have planned for my game, or do little flip animations to make it more likable. As i have never made a flying companion before, I would like to know if there is a good way to make a dynamic flying character in unity before I dive headfirst into a solution that I think is right but might be flawed. Any help appreciated :D:D:D
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,691
    In the companions I've made before I usually define a ring of possible positions around the player, and the companion agent chooses which of those positions it wants to use and moves towards that position.

    That lets the companion use the same (or another) pathfinding to get there.

    As for flying pathfinding, there's lots of ways to tackle that ranging from a separate mesh just for flyers to having invisible proxy ground-based objects that follow that mesh and tell the flying agent above them were to go, etc.

    Fiddle with it a bit... your brain will soon start to light up to the possibilities. :)
     
    karsten-heim likes this.