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

**URL:** <https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139>\
**Category:** Game Development\
**Tags:** unreal-engine\
**Created:** [March 6, 2015, 8:01pm UTC](https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139 "2015-03-06T20:01:23Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![anonymous\_user\_36e35587](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_36e35587](https://forums.unrealengine.com/u/anonymous_user_36e35587)\
**Post date:** [March 8, 2015, 7:04pm UTC](https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139/21 "2015-03-08T19:04:00Z")

</div>

> [@;241164](#):
>
> 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.

That is odd behavior. Once I have time to access the Lab Computers with UE4, it should be an easy fix (maybe tonight, no promises ;)). Nice Caustics BTW!

Oh and a good piece of information about turnFrequency: it is the number of seconds before the leader generates a new seek target vector coordinate. In human, that means they will wait however long turnFrequency is set to before turning (looping). The lower turnFrequency is set to, the more they turn (It does seem a little backwards).

I thought maybe was due to turnFrequency, but it is not the case, since you had your value set low. My best guess at time is he is fleeing from something (maybe your player haha… (default behavior is to flee from player at the moment XD))

Cheers,

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d47e65fe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d47e65fe](https://forums.unrealengine.com/u/anonymous_user_d47e65fe)\
**Post date:** [March 8, 2015, 11:36pm UTC](https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139/22 "2015-03-08T23:36:30Z")

</div>

Ahhh…so that’s what turnFrequency does. I thought it was for a rotation. Makes sense now.

Thanks for the comment on the caustics. The unfortunate part is that it could look soooo much better with the UE4 engine, but I’m targeting VR so you really need to watch post-process there.

BTW, you take any other donation methods besides BC? Would like to help support you guys with something to keep things going.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_36e35587](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_36e35587](https://forums.unrealengine.com/u/anonymous_user_36e35587)\
**Post date:** [March 9, 2015, 1:43am UTC](https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139/23 "2015-03-09T01:43:56Z")

</div>

> [@;241618](#):
>
> Ahhh…so that’s what turnFrequency does. I thought it was for a rotation. Makes sense now.
> 
> Thanks for the comment on the caustics. The unfortunate part is that it could look soooo much better with the UE4 engine, but I’m targeting VR so you really need to watch post-process there.
> 
> BTW, you take any other donation methods besides BC? Would like to help support you guys with something to keep things going.

Hey ,

I created a default scene and added fish and was getting the you were talking about. I played around a bit with the bounds of the volume and debugged the c++ file. It turns out what your fish are doing is either they are already outside of the bounds of the volume on play (and unable to get back in) or, as in my case, they were fleeing beyond the bounds of the volume from the player and continuing on. I enlarged the volume size and all is well. Try making yours really big. The next thing I’ll be working on is a ray casting system for determining if they will hit the surface of the volume, so that is not even an.

Also, add line to function in FlockFish.cpp:

bool AFlockFish::isNearObstacle(float delta)  
{  
\*\*return false; \<- ADD \*\*  
FVector location = -\>GetActorLocation();  
FVector maxBound = FVector(0, 0, 0);  
bool nearAObstacle = false;

```
if (location.Z + obstacleDist &gt;= maxZ){
	maxBound = FVector(curVelocity.X, curVelocity.Y, curVelocity.Z - (obstacleDist * 2));
	FRotator avoidRotation = FRotationMatrix::MakeFromX(-&gt;GetActorLocation() - maxBound).Rotator();
	curRotation = FMath::RInterpTo(-&gt;GetActorRotation(), avoidRotation, delta, turnSpeed);
	nearAObstacle = true;
}
else if (location.Z - obstacleDist &lt;= minZ)
{
	maxBound = FVector(curVelocity.X, curVelocity.Y, curVelocity.Z + (obstacleDist * 2));
	FRotator avoidRotation = FRotationMatrix::MakeFromX(maxBound - -&gt;GetActorLocation()).Rotator();
	curRotation = FMath::RInterpTo(-&gt;GetActorRotation(), avoidRotation, delta, turnSpeed);
	nearAObstacle = true;
}

return nearAObstacle;

```

}

will remove their avoidance of surface and sea floor, which is good, because it is currently buggy X.X

 ![ae709d67ce5c3d69c529bac35b3cefb8f127c0f0.jpeg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/e/7/ae709d67ce5c3d69c529bac35b3cefb8f127c0f0.jpeg)

Also added a paypal option for donations, at the top of the page and here:

 ![Flocking.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/e/7/ae709d67ce5c3d69c529bac35b3cefb8f127c0f0.jpeg)]()

Thanks in advance for any donations!

Cheers,

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_36e35587](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_36e35587](https://forums.unrealengine.com/u/anonymous_user_36e35587)\
**Post date:** [March 9, 2015, 2:10am UTC](https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139/24 "2015-03-09T02:10:22Z")

</div>

As per request, here is the link to a (4.6) project with mackerel schooling:

---

<div class="post-metadata">

**Author:** ![kkhaial](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kkhaial](https://forums.unrealengine.com/u/kkhaial)\
**Post date:** [March 9, 2015, 10:33am UTC](https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139/25 "2015-03-09T10:33:40Z")

</div>

> [@;241694](#):
>
> As per request, here is the link to a (4.6) project with mackerel schooling:

Thanks for taking the time to do that, donation sent…

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_36e35587](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_36e35587](https://forums.unrealengine.com/u/anonymous_user_36e35587)\
**Post date:** [March 11, 2015, 2:58am UTC](https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139/26 "2015-03-11T02:58:52Z")

</div>

> [@Triplelexx;239746](#):
>
> 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.

@Triplelexx, I just uploaded the code I’ve been working on to [GitHub](https://github.com//FishPackage), feel free to fork and make some cool stuff!

@Everybody, I just rewrote the fish into a state machine in C++, it is a LOT cleaner now! I also completed enemy detection optimization. All the updates can be seen on the [Trello Board](https://trello.com/b//fish-schooling-ai-and-assets-package), and can be accessed currently through [GitHub](https://github.com//FishPackage). The next three things I plan on doing are releasing package v0.2, uploading a detailed instructional video to youtube, and fixing fish going outside of bounds through Raycasting.

~

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d47e65fe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d47e65fe](https://forums.unrealengine.com/u/anonymous_user_d47e65fe)\
**Post date:** [March 11, 2015, 3:43pm UTC](https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139/27 "2015-03-11T15:43:14Z")

</div>

Awesome . Just did the donation so hopefully others will contribute as well and keep going!

BTW, will you be able to post your underwater pp and FX details?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_36e35587](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_36e35587](https://forums.unrealengine.com/u/anonymous_user_36e35587)\
**Post date:** [March 12, 2015, 1:48am UTC](https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139/28 "2015-03-12T01:48:39Z")

</div>

> [@;244266](#):
>
> Awesome . Just did the donation so hopefully others will contribute as well and keep going!
> 
> BTW, will you be able to post your underwater pp and FX details?

@ & @kkhail, Both my artist and I are extremely grateful for the donations! The more we get the more art assets we’ll be able to include and the more time I can commit to making package awesome, so thank you both. As for the underwater FX, I’ll talk to my friend and let you know, if he says we can use it, then I’ll be sure to include them in V0.2 of the package. Thanks again!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0df12f74](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0df12f74](https://forums.unrealengine.com/u/anonymous_user_0df12f74)\
**Post date:** [March 12, 2015, 8:23pm UTC](https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139/29 "2015-03-12T20:23:39Z")

</div>

Hey man, finally got a to take a look through it all morning, it looks great!! I will be adding the code over the coming days now that the plugin is working, thanks again for all of ! 😃

p.s. The [GitHub build](https://github.com/UE4-OceanProject/OceanProject/tree/) is now up for 4.7.2! Are you guys still using 4.6? If so I can upload that version as well, let me know.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_36e35587](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_36e35587](https://forums.unrealengine.com/u/anonymous_user_36e35587)\
**Post date:** [March 12, 2015, 11:07pm UTC](https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139/30 "2015-03-12T23:07:50Z")

</div>

> [@;245560](#):
>
> Hey man, finally got a to take a look through it all morning, it looks great!! I will be adding the code over the coming days now that the plugin is working, thanks again for all of ! 😃
> 
> p.s. The [GitHub build](https://github.com/UE4-OceanProject/OceanProject/tree/) is now up for 4.7.2! Are you guys still using 4.6? If so I can upload that version as well, let me know.

Yep we’re still using 4.6 for our project, can’t wait to check out the new build!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0df12f74](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0df12f74](https://forums.unrealengine.com/u/anonymous_user_0df12f74)\
**Post date:** [March 12, 2015, 11:21pm UTC](https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139/31 "2015-03-12T23:21:53Z")

</div>

> [@;245687](#):
>
> Yep we’re still using 4.6 for our project, can’t wait to check out the new build!

Ok no problem, I’m sure there are many others as well so it is in the works.

I created a GiitHub organization for the project, if you want to be a part of it just PM me your info, but I understand if you can’t you are probably pretty busy right now! 😉

Cheeers man, I will have 4.6 up by tomorrow.

-

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_36e35587](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_36e35587](https://forums.unrealengine.com/u/anonymous_user_36e35587)\
**Post date:** [March 13, 2015, 4:27am UTC](https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139/32 "2015-03-13T04:27:40Z")

</div>

Hey everybody,

I just added some more optimization to the fishes in addition to making the variables a lot more clear and splitting them into sections. Still working on packaging a V0.2, but if you want the latest get the code from [GitHub](https://github.com//FishPackage).

Also: Would any of you be interested in seeing me add a harpoon gun with realistic rope physics? My friend has been working on realistic ropes [here](https://forums.unrealengine.com/showthread.php?61565-Dynamically-Generated-Ropes&highlight=dynamic+rope), and the code involved wouldn’t be too hard to have fish be killed and reeled in by a harpoon gun. I, of course, would need to convince my friend first ;).

~

---

<div class="post-metadata">

**Author:** ![makai](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@makai](https://forums.unrealengine.com/u/makai)\
**Post date:** [March 13, 2015, 4:49am UTC](https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139/33 "2015-03-13T04:49:55Z")

</div>

is so awesome, thank you so much!

---

<div class="post-metadata">

**Author:** ![kkhaial](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kkhaial](https://forums.unrealengine.com/u/kkhaial)\
**Post date:** [March 13, 2015, 10:33am UTC](https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139/34 "2015-03-13T10:33:47Z")

</div>

> [@;245862](#):
>
> Hey everybody,
> 
> I just added some more optimization to the fishes in addition to making the variables a lot more clear and splitting them into sections. Still working on packaging a V0.2, but if you want the latest get the code from [GitHub](https://github.com//FishPackage).
> 
> Also: Would any of you be interested in seeing me add a harpoon gun with realistic rope physics? My friend has been working on realistic ropes [here](https://forums.unrealengine.com/showthread.php?61565-Dynamically-Generated-Ropes&highlight=dynamic+rope), and the code involved wouldn’t be too hard to have fish be killed and reeled in by a harpoon gun. I, of course, would need to convince my friend first ;).
> 
> ~

wow that would be great

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_36e35587](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_36e35587](https://forums.unrealengine.com/u/anonymous_user_36e35587)\
**Post date:** [March 14, 2015, 5:34am UTC](https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139/35 "2015-03-14T05:34:52Z")

</div>

Been working on obstacle avoidance tonight. I made some good progress, but wasn’t able to get it where I want. Once that is done I’ll feel confident in posting a new video where I create a quick aquarium scene in UE4.

Hakuna Mattata,

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_36e35587](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_36e35587](https://forums.unrealengine.com/u/anonymous_user_36e35587)\
**Post date:** [March 15, 2015, 4:25am UTC](https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139/36 "2015-03-15T04:25:07Z")

</div>

Hey guys,

I made part 1 of a 2 part video tutorial for implementing my fish into your own game. I also released v0.15 of the fish package above.

Cheers,

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_36e35587](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_36e35587](https://forums.unrealengine.com/u/anonymous_user_36e35587)\
**Post date:** [March 16, 2015, 4:52pm UTC](https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139/37 "2015-03-16T16:52:04Z")

</div>

Here’s a video of my updated fish:

Hakuna Matata,

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_36e35587](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_36e35587](https://forums.unrealengine.com/u/anonymous_user_36e35587)\
**Post date:** [March 16, 2015, 10:43pm UTC](https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139/38 "2015-03-16T22:43:24Z")

</div>

Just got word from my friend that I can include his rope physics and caustics in package. So a big thanks to [Regalith](https://forums.unrealengine.com/member.php?29239-Regalith). I’ll add his stuff when I have time. Cheers!

---

<div class="post-metadata">

**Author:** ![kkhaial](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kkhaial](https://forums.unrealengine.com/u/kkhaial)\
**Post date:** [March 17, 2015, 3:50am UTC](https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139/39 "2015-03-17T03:50:20Z")

</div>

Awesome stuff , and thanks Regalith for the rope physics and caustics…

Can anyone explain how I can add an animation to when the shark attacks to open his mouth? or turn left and right animations?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_36e35587](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_36e35587](https://forums.unrealengine.com/u/anonymous_user_36e35587)\
**Post date:** [March 19, 2015, 1:20am UTC](https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139/40 "2015-03-19T01:20:38Z")

</div>

Hey guys,

Just got caustics available through the [Ocean Demo](https://github.com/UE4-OceanProject/OceanProject/tree/) github. Checkout the branch for both caustics and working fish!

[Previous page](https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139.md?page=1)

[Next page](https://forums.unrealengine.com/t/community-wip-fish-schooling-ai-and-assets-package-open-source/23139.md?page=3)
