[Community WIP] Fish Schooling AI and Assets Package (Open Source)

[FONT=Arial Black]Fish Schooling AI and Assets Package


Please vote on things you want implemented on the Trello Board

These fish models and code have been added to the Community Ocean WIP! , , and myself will be collaborating to bring you the best complete community ocean possible!


Recently I have been working with a team of 4 others on a serious game for my senior project. The game was mostly set in a underwater environment, so there were a lot of fish behaviors and 3D Models to be created. I personally implemented the schooling behaviors using Boids Behaviors, while my artist created the models and textures for a lot of fish. Our time developing the game is almost over, so we wanted to leave the community with something that will allow people of almost every skill level to implement good looking fish into their game! I hope to continue development on the fish logic, and my artist may be convinced to create more fish ;). If you have any ideas on how to improve our AI, or if you are an artist that wants to contribute your own fish, please do! I will add you to the list of contributors.

If you use in your project, I would be more than delighted to see video of your game posted here!

Older videos:
UE4 Underwater Environment
UE4 Fish Flocking


  • (Kyle Bryant) - Fish AI and Thread Creator

  • PatPetersen127 (Patrick Petersen) - Original Fish Models and Textures


ALL ASSETS: https://drive.google.com/folderview?id=0B2UNs-YOzEliSDgxWWxPUldOWjQ&usp=sharing

Are you an artist? Would you like to be listed as a contributor? Submit a textured fish or underwater creature through Texture and .FBX that is scaled correctly and is facing the +X direction and I’ll add it here with your name! For bigger underwater creatures please include a swimming animation, not required for smaller fish. Also submit an image of the fish that is similar in size to the ones listed below…






  • Schooling Behaviors
  • Fleeing Behaviors
  • Seeking Behaviors
  • Chase Behaviors
  • Fish Manager for Easy School Creation


Ocean Demo GitHub
repository contains both underwater caustics and schooling fish!

On a more ironic note: both my artist and myself are Pisces working on a Fish package XD

Hey guys! I’m the artist that made the fish. I tried to keep them pretty low poly so that you could have lots of flocks and larger schools. Only the biggest creatures (like the sharks) have animations, the rest look fine just moving regularly through an environment. I also researched the average sizes of all the fish so that you can scale them appropriately. I hope you guys enjoy the models! Feel free to ask me any questions.

Wow is incredibly generous and cool!

I’m very interested in sort of AI behaviour, and love fishies!
If you put the code on Github it would be easier to contribute to.

Looks awesome, great work guys…

How do I add to my project?

is awesome! Thank you :slight_smile:

ooh very nice, thanks!

@Triplelexx, Thanks, I will move it to github as soon as I am able. Was packaging project for senior project today, so just posted what I was able to :).

@kkhaial, I will post a tutorial video as soon as I can, but for now I will leave you with these (rather scant) instructions:

FlockFish and FishManager Instructions

-> Add Code To Project (2 Files: FishManager and FlockFish)
-> Create a Blueprint that extends FlockFish, and another that extends FishManager
-> Add a mesh to your FlockFish Blueprint
-> Ensure under default config of your FlockFish blueprint that:

  1. playerType is set to your player blueprint.
  2. neighborType is set to the fish’s own blueprint
  3. MaxBounds and MinBounds is set to the bounds of the volume you want the fish to swim around in. (Ignore part if utilizing fish manager)

-> Option 1: No Fish Manager

  1. Place your FlockFish BluePrint in level, ensure isLeader is set to true.
  2. Copy/Paste your leader, and ensure isLeader is set to false on the copy.
  3. Copy/Paste your copy as many times as you want… Tada… Fish Flocking

-> Option 2: Utilizing Fish Manager

  1. Drag a FishManager Blueprint into your level
  2. Set MaxBounds and MinBounds to the bounds of the volume you want the fish to swim around in.
  3. Add a your FlockFish Blueprint to the “FlockType” section in fishmanager
  4. Set how many fish you want in the flock by setting the float value under “FlockNum” section in fishmanager

How do I add the code?

Although not the prettiest way, what I would do is from the menu select “File->Add Code to Project…” and make sure that the parent class is Pawn (You may have to select the ‘all classes’ tick). Name the file “FlockFish”. Copy paste all my code over into the .h and .cpp files for FlockFish. Do again for “FishManager”, but with its parent class as Actor. If anybody knows a better solution for adding external code to project, please enlighten me :stuck_out_tongue:

Added a Trello Board: https://trello.com/b/. Vote on what you want to see next, or if you have a suggestion on a card to add, let me know here!

Gave that a try, it’s crashing when I simulate. can you maybe upload the project folder?

Ahh, ok. That’s actually an with the fish code itself. Right now at runtime the fish code is trying to find the specified player blueprint in world, but when you simulate your player is not spawned, so the fish are throwing around nulls everywhere. My advice for now would be to play, then eject rather than simulating. I will be sure to fix in the next version. As for uploading the project folder, I will setup a scene and post a project as soon I get a to go up to the School’s lab.


Thanks , Can you share your post processing settings for your underwater scene?


First, is simply awesome! Thanks so much for sharing the code.

Looking forward to post-processing!

Lastly, I did add the code as per your instructions, but when I add it to my skeletal mesh and play, the fish just shoot straight-up, regardless of how I set the Underwater Min and Max. Any ideas or anyone else having the same?


@kkhail, I’ll have to wait to giving you the Post Process Volume. I need to ask my friend if it is ok to distribute it, but if he says yes, I will definitely let you guys have that.

@, How many units is the Z of your bounds? I ask because the code for checking if a fish is close to max bounds was made hastily so that it would work for my groups senior project. My current code (planning a fix for with ray casting) adds and subtracts “obstacleDist” for the fishes z location to check if it is close to the surface or sea floor. value’s default is set to 300, which may be way too much depending on the size of your bounds, but can be turned down. That may be the you’re running into, if not let me know :slight_smile:


Thanks for writing back so quickly!
Well, I’ve tried a few parameters for Z. I’ve used the fish manager as well as just setting it on the fish mesh itself, but it’s always the same result. I’ve even tried setting the min to 1 and the max to 5.

I’ve also lowered the obstacleDist variable and the result is the same.

Interesting, I will go up to the lab sometime week (Spring Break) and test out the fish on a fresh project to see if I run into something similar. If you have any video or images of the that would help too!

Also: What do you have set for the fish’s ‘turnFrequency’?

Yeah, pretty strange. I was hoping you’d be able to drop it in an empty project to test so thanks!

I left the turnFreq at 1, but I did test it with others and didn’t make a difference.

Screenshot is attached but you can’t really get an idea for what’s going on. You’ll see the Mako (haven’t fixed it’s rotation but no big-deal), and it just flies straight-up.

What’s the license on the art assets? CC0? Or something more restrictive?

Found somebody who said in the forums, I believe covers project as well:
is released under the CC0 1.0 Universal license meaning you can use it however you want with no attribution. Although if you’re using them in some kind of finished project it would be cool to let me know where!