SevenSeasToGlory - Programmer Sprint 6

SevenSeasToGlory - Programmer Sprint 6

 Ship Swaying Away From Islands 

I got tasked with a card to have the Enemy Ships not collide and or run into the Islands. Being that the Islands are a super huge priority in this game we wanted the player feel immersive while playing so giving this task it's just right.

Recruit Enemies

This has been a highly requested element from our lead. She has always been asking for ally pirates. Given when you defeat a pirate a text prompt will pop up either sparing the pirate or defeating the pirate and if you spare the pirate, the pirate will be on your side fighting off other pirates. 

Ally Pirates Fight Enemy Pirates

I was also given a card when you recruit a pirate, that pirate would have to defend and protect you. 

Friendly Pirate Class

My producer also gave me a task to create a friendly pirate class. This was super easy because I just inverted a pirate class and ran with it. It has all the basic fundamentals of a pirate and even has the same animator controller which did not bug out.  

Waves / Ocean Generator

With the waves we have been struggling with this for a while. We first used a free Unity asset water that our professor let us use by asking. Unfortunately that did not seem to render on our build so the sea would just be blank. Then I manually made a water but the tiling was off when I put them in an Ocean Generator script. After I just bought a water asset, it was half off and I put that in my ocean generator script that I made and it turned out pretty nice. 

Cannon Bug Fix

For the Cannon Bug Fix I completely made a whole new cannon script and revised the code. Fixed the code from being local space to world space. 


Problem I Encountered On the Way

I didn't encounter too many problems. Fixing the CannonBall was kind of a bit of a struggle for a day and half because I wasn't too sure why the cannons z rotation was being affected by the ships rotation I looked up on Unity's forum about different transforms and their directions and the OceanGenerator because I was interating through a nested for loop. Also, The FindClosestEnemy() function and having it update as the pirate encounters new pirates. Either than that I didn't have too many trouble.

Logic


For the Cannon Ball Bug Fix I completely re did the script. I am not sure who made the first cannon ball script but they manually created a vec3 position for the firing point and positioned it the world axis and started shooting the cannon balls from there and sometimes it worked and most of the time it didn't. Instead I completely changed the script and added an empty game object and created that as the firing point and took it's z axis and shot a transform.TransformDirection(vec3.forward) and changed it's local position to a world position so now with the ship rotation it will match the cannon firing point z position so there won't be any bugs. I was also testing out velocity which I thought would be ideal for bullets but AddForce() seemed more smoother. 

For the Ships avoiding each Island, it's actually in the Ship's Patrolling and AvoidingObstacle() funcitons. It is also the same piece of code. I actually never changed anything in the ShipAI script. The code remains the same. All I did was create a new layer because of how universal the script is and how I created it. I created a new layer called "Islands" and slapped box colliders on all the island. Then in each Pirate AI Ship I added the "Islands" layer to the obstacleLayer.
-----------------------------------------------------------------------------------------------------------------------------

For the Waves, Like I mentioned previously our professor in the beginning of the semester let us use an asset from a store but the ocean never rendered in our build so I manually created an ocean and it was pretty difficult. The good news is that it rendered in the build, but my ocean generator script didn't add up the tiles together to make it look like an ocean. It created the ocean tile by tile but there were schemes in each tile so it just looked weird. My fix was to just purchased a water tile from the Unity asset store and in my ocean generator script it actually looks really good as far as a ocean and it builds as well.


For the Friendly ally pirate. It's a just a whole revamp of the pirate class. Just opposite. It also makes it easier that each enemy pirate is tagged enemy. I added new elements to the pirate class too like finding the closest enemy, teleporting the pirates to the ship, and attacking enemies. The pirate class will locate and find the closest enemy within a maxDistance and returns the closestEnemy if there is an enemy within the maxDistance. I made it universally specific so as the friendly pirate updates enemy. Meaning that if it locks onto an enemy and you don't kill that enemy and you go to a different enemy it will update. 



When you gather recruits you can also TP them back to your location. When you are done and want to go back to your ship, island or other pirate ship you TP them to your location to help fight you in battle!




For the actual Recruitment of the friendly Pirate lays inside the ImperialPirate script. As it takes damage it calls the Die() function which has the recruitmentText which a specific message is typed. If you press J it spawns a friendly pirate which I explained above and all it's elements, if no, it destroys the gameobject.


For the Ocean Generator I grabbed the water tile and in my GenerateTile() function it iterates through each tile count and clumps them together to mimic an ocean with just one tile. 

Aftermath






Comments

Popular posts from this blog

CAGD Portfolio

495 - Sprint 1