Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module 2 Assignment Work Documentation #40

Closed
12 tasks done
jaakop opened this issue Sep 26, 2023 · 6 comments
Closed
12 tasks done

Module 2 Assignment Work Documentation #40

jaakop opened this issue Sep 26, 2023 · 6 comments
Assignees

Comments

@jaakop
Copy link
Contributor

jaakop commented Sep 26, 2023

Mark issues done when documented. Deadline is 9. October, so a few days in advance would be NICE =)

Introduction:

Brief introduction, skill level, current know-how, your role in the project, also what you are responsible of.

Completed tasks:

Show code/screenshots of functionalities you've created. Explain what the heck it does in text too. Show components, assets etc.

In-progress tasks:

Same as above. If you don't got any tasks in-progress, you can write, that you don't have anything etc.

Emil

  • Introduction
  • Completed tasks
  • In-progress tasks

Aleksandar

  • Introduction
  • Completed tasks
  • In-progress tasks

Jaakko

  • Introduction
  • Completed tasks
  • In-progress tasks

Leevi

  • Introduction
  • Completed tasks
  • In-progress tasks

Afterwards comment them below

@jaakop
Copy link
Contributor Author

jaakop commented Sep 29, 2023

Introduction

Jaakko Sukuvaara - I've worked as a software developer with medical software in C# for 2.5 years. Before that I studied in vocational school to become a software developer. I've done video games as a hobby since 2015 and have done game jams in FGJ.
My skill level for this course is advanced, I know C# and Unity very well. My role in the project has been programmer and project manager. I've developed game systems (Fish behaviors and world generation) and managed the project.

Completed tasks

Fish

Class diagram

classDiagram
%% Prefabs
BoidFish ..|> Fish1
Fish ..|> Fish2
Fish ..|> Fish3
Fish ..|> Fish4
HunterFish ..|> Shark
<<Prefab>> Fish1
<<Prefab>> Fish2
<<Prefab>> Fish3
<<Prefab>> Fish4
<<Prefab>> Shark
%% Classes
FishController <.. Fish
Fish --|> DetectingFish
DetectingFish --|> BoidFish
DetectingFish --|> HunterFish
<<abstract>> DetectingFish

class FishController {
+Vector3 fishBoundingBoxOffset
+Vector3 fishBoundingBoxSize
-List~GameObject~ fishList
+KillFish(GameObject Fish) void
+IsFish(GameObject) bool
+MovePointInsideBounds(Vector3 point, float moveAmount) Vector3
}

class Fish {
-FishController controller
+FishController Controller
#float speed
#Move() void ~~virtual~~
#CreateNewTarget() Vector3 ~~virtual~~
+Kill() void
}

class DetectingFish {
#List~Collider~ closeColliders
#FilterCollider(Collider) bool ~~abstract~~
}

class BoidFish {
-float randomDirectionWeight
+GetDirection() Vector3
#CreateNewTarget() Vector3 ~~override~~
#FilterCollider(Collider) Vector3 ~~override~~
}

class HunterFish {
-float huntingSpeed
-bool hunting
#Move() void ~~override~~
#FilterCollider(Collider) bool ~~override~~
}
Loading

FishController

The fish controller keeps track of the fish in the game and defines the bounds where the fish can move. In the image below the bounds can be seen with the green outline.
Pasted image 20230929113314
Method in FishController for checking that the fishes stay in bounds

/// <summary>
/// If the given point is outside of the bounds. Move it inside the bounds
/// </summary>
/// <param name="point">The point to move</param>
/// <param name="moveAmount">Amount that is possible to move the point by</param>
/// <returns>Point inside bounds</returns>
public Vector3 MovePointInsideBounds(Vector3 point, float moveAmount)
{
    if (point.x < fishBoundingBoxOffset.x - fishBoundingBoxSize.x / 2 ||
        point.x > fishBoundingBoxOffset.x + fishBoundingBoxSize.x / 2)
    {
        point.x += point.x < fishBoundingBoxOffset.x ? moveAmount : -moveAmount;
    }
    if (point.z < fishBoundingBoxOffset.z - fishBoundingBoxSize.z / 2 ||
        point.z > fishBoundingBoxOffset.z + fishBoundingBoxSize.z / 2)
    {
        point.z += point.z < fishBoundingBoxOffset.z ? moveAmount : -moveAmount;
    }
    if (point.y < fishBoundingBoxOffset.y - fishBoundingBoxSize.y / 2 ||
        point.y > fishBoundingBoxOffset.y + fishBoundingBoxSize.y / 2)
    {
        point.y += point.y < fishBoundingBoxOffset.y ? moveAmount : -moveAmount;
    }
    return point;
}

Normal Fish

Pasted image 20230929115400
The normal fish only swims around and doesn't care about the other fish. It moves by creating a waypoint in a random direction and each time it gets close enough to the waypoint it generates a new one.

Fish movement

var newDir = Vector3.RotateTowards(transform.forward, target - pos, turningSpeed * Time.deltaTime, turningSpeedChange);
transform.position += newDir * (speed * Time.deltaTime);
transform.rotation = Quaternion.LookRotation(newDir, Vector3.up);

New vector 3 newDir is created with Vector3.RotateTowards method. That method gets two vectors: current forward direction and target direction. Then it turns it by a given amount. In this case turningSpeed * Time.deltaTime.
Then the new direction is applied to the transofrm as its rotation and moved into that direction by given amount speed

Creating new target

var point = transform.position + UnityEngine.Random.rotation * Vector3.forward * UnityEngine.Random.Range(minTargetPointDistance, maxTargetPointDistance);
return controller.MovePointInsideBounds(point, maxTargetPointDistance);

To create a new target Unity engine Random.rotation is used and converted from quaternion to Vector 3. Then, because it is a unit vector, it is multiplied with a random value between given max and min distances. Then the point is moved back inside the bounds of the controller if it is outside of them.

DetectingFish

The DetectingFish creates a collider of given size on start to sense close colliders. It adds new colliders to its internal list if the FilterCollider method returns true when the collider is given to it.

if (other != null && FilterCollider(other))
{
    closeColliders.Add(other);
}

Then the collider is remove from the list when it leaves the trigger collider.

Boid Fish

For the boid fish the goal was to create flocking behavior with the Boids rules. Due to implementation of fish movement I implemented only one of the three main rules: alignment.
Pasted image 20231001131016
The boid fish inherit the detecting fish and whenever they are creating a new waypoint they get the average direction of nearby fish with the same tag. Then they create a new waypoint in that direction with small randomness applied to it in rotation and length.

avarageDirection = avarageDirection.normalized;

var point= transform.position + ((Random.rotation * Vector3.forward * randomDirectionWeight) + avarageDirection) * Random.Range(minTargetPointDistance, maxTargetPointDistance);

Hunter Fish

Pasted image 20230921202541
The shark inherits the detecting fish and when its attack timer is off cooldown and it is close to prey it starts attacking it. It abandons its old move target and starts moving towards its closest prey target. Once the shark is close enough it kills the prey fish by calling the fish controller with the fish object. Then the prey fish is deleted, a particle effect spawned in its place and the shark attack timer is set to cooldown.

var closestPrey = closeColliders.Where(o => o != null).Select(o => o).OrderBy(o => (pos - o.transform.position).magnitude).First();
var closestPreyPos = closestPrey.transform.position;

World Generation

The world map is implemented with random world generation that uses environment prefabs that are then spawned into the scene when the scene starts from a weighted list.
Pasted image 20231001133056
The position and number of these spawned in prefabs can be adjusted in the GameControllers WorldController script.
Pasted image 20231001133135

for (int i = 0; i < numberOfPlaces; i++)
{
    Instantiate(RandomUtil.GetRandomElemntFromWeightedList(envPrefabs.Select(p => new System.Tuple<GameObject, float>(p.prefab, p.weight * 0.1f)).ToList()),
        transform.position - new Vector3(spacing * numberOfPlaces / 2 - spacing / 2, offsetY, 0) + new Vector3(i * spacing, 0, 0),
        Quaternion.identity,
        envTransform);
}

Pasted image 20231001133324

In-progress tasks

My next tasks would be to fix the shark code as they start throwing errors and get stuck and clean up its code on the way. Then make the fish avoid colliding with the environment. And last on the list for now is to make the fish catch on the hook, when the hook is ready for it. When these are done I'll see what else needs doing or if others need help

@Emiliontti
Copy link
Contributor

Introduction

Emil Kola – A newcomer on the fields of game development. First time I touched Unity was when the entrance exams started. Made a small 2D game called Mow Them Down while doing the ex-ams. I’ve studied business information technology on vocational level, which focused mainly on C++ (12 years ago).
My skill level is probably somewhere between beginner-intermediate. I’ve programmed the input system in the game, as well as been responsible of the casting. Also coordinated a lot of the visual assets, as well as visual output. My role has been a programmer and a game designer.

In-progress tasks

Next I'm trying to create and refine the gameplay loop, by tweaking the inputs (to allow mouse inputs) and also to continue making the gameplay more fun! This means collaboration with Alexandars and Jaakkos parts, making the underwater fishing line and making the inputs and minigame and catch system according this following concept:
image

@jaakop jaakop changed the title Document done work Module 2 Assignment Work documentation Oct 2, 2023
@jaakop jaakop changed the title Module 2 Assignment Work documentation Module 2 Assignment Work ocumentation Oct 2, 2023
@jaakop jaakop changed the title Module 2 Assignment Work ocumentation Module 2 Assignment Work Documentation Oct 2, 2023
@Laffey-chan
Copy link
Contributor

Laffey-chan commented Oct 3, 2023

Introduction

Leevi Kankainen
Somewhat new in game development field, but i have some experience with unity as an engine from personal small project's and from vocational school. i studies in vocational school in information and communication technology as c# programmer. For c# i have a done own project for automation stuff for me and quality of life programs for game information for me and some game modding if the game have been unity based.

I also have some skill in blender, but most of the information / knowlegde of blender i have forgotten because i haven't used blender for some time, but some basic i still have the knowlegde

My skill level is somewhere in intermidiate level.

What have i done this far for the game has been, For model's that we use to add bone's so we could animate the fishes and done the animation for the swim in unity animation and i have done the fish spawn for the game that the fishes spawn outside of the camera

Task that i have done

Here is kinda more in dept what have i done if i have not documented in issues that what have i done.

Fish Bone's

Because i have putten some images for the issue i will link the issue here and there you can see all the fishes and how the bones are on the fishes

Adding bone's to the fishes · Issue #18 · Fisherman-s-Friends/Fisherman-s-Friends (github.com)

But For some documentation information i did not write at that time, But here is some information about this

The fish asset that we used didn't come with bone's / weight map, so somebody needed to add bone's to the fishes, so we could animate them better with the unity's own animation file / animator. So i added them to the fishes

Animation

Also here is kinda same that i putted images/gif to the issues i will link the issue where you can see the images/gif in action.

Animate fish moving · Issue #15 · Fisherman-s-Friends/Fisherman-s-Friends (github.com)

But i didn't document some information what else i did for the animation, so i will put the information here.

The fish has 2 difrent animation for slow and fast swimming. I also edited the curve of the animation so the animation look's more smooth because it's looping so it''s not spiky and here is the image of the curve of one of the fishes, because allmost everyone have same kinda curve.
image

Fish spawning

How i spawn the fish is called in update but it's timed how long it need's to wait for spawning and it also checks if there is max amount fishes it will not spawn anymore

image

The SpawnFish method has a instantiate that is stored to var and added to list and i also do vector were the fish spawn's outside of the bounding box / camera so they come from the outside, there is also a calculation methed that returns the x cordinate for the fish were it spawn

image

I also use struct were is the GameObject and the weight of the fish, of what is the wight of it spawning when spawn is called.

image

Fish script editor

Here is what is look's like the both tab's

image
image

I also made a fish script editor for unity show in the inspector the fishcontroller show difrently and it's not long and it has the correct tabs for the fish controls (it's very basic that i did know how to do)

image

There i use #region and #endregion to short them because you don't need to see them allways.

Firstly because the variable's are serializedproperties and private i need to do in the beginning the serializedproperty namin of the variables

image

then there is also were i put the data to the fields on the OnEnable method / function were i use the FinProperty were unity finds the serialized propertys type and data and put that tp the variable's

image

Then i override the OnInspectorGUI method were i update the inspectors to add the propertyfield with the variable so it show in the inspector and i also make the toolbar tabs for the int variable because i need to know the value of the tab what user clicks

image

And because they are serializedObject / fields i need to ApplyModification also show the value updates to the variable so it's not astetic

To-do list

I have a inventory in todo-list were i am doing the inventory for the fishes and we were thingking of doing kinda like tarkov style inentory were you can rotate and the difrent fishes has diffrent that they take space in the inventory

image

(this is might)and also when you click the fish there might be like new window were it show the fish and maby some description and button to discard the fish so you can have more inventory space

@Emiliontti
Copy link
Contributor

Emiliontti commented Oct 7, 2023

Completed tasks, Emil

A boat, a rod (and the open sea...)

So, the first thing I started with the project, was to find suitable assets for the boat and the rod, and the bobber, to make the casting system and figuring out the gameplay loop. The rod and the boat were both free assets from the Unity asset store, and just needed a few tweaks to get them to fit:
image

The rod is slightly scaled from the original model, but it looks way more fitting with the chunkier scale for the shaft. The boat was originally a bit more inhabited with boxes and a flagpole in the keel of the boat. I went and removed those to make some room for the rod.
image

And here’s where the current setup is right now:
image

Then I proceeded to add a bobber object to act as the point that flies into the water, when the player gives input to cast the line:
image

I also added a LineRenderer component (more on that in the next sections) from the rod to be created to the bobber, and from the bobber to the hook as well:
image

Input Action Mapping and the Controls system

So, I was in charge of making the controls for the game. I looked into the old input system, but a 2nd year student recommended, that Unity’s new input system could be worth looking into as well, so I figured I’d try it out. The input system is downloaded through the package manager and is installed for the project:
image

I went through a few simple steps to set the system up, first I made the action map for keyboard controls, and later I implemented mouse action too to work in unison with the casting (so you could either use keyboard and mouse, or either/or):

image

As of documenting, there’s keys to Cast the line with the CastLine action, and keys to Reset the line with the ResetCast keys. The HookActions mapping is a WIP, but it includes a different action map which changes the actions to do different stuff. This I saw useful, because when the line is cast, and the hook is generated you needed different actions, but you could still utilize the same keybinds to do stuff.
image

The calling of the actions is done inside the GameController object, that inhabits different controller scripts for the game. I added the Player Controller script and also the Player Input -component to the object:
image


The PlayerController script holds the input system for the game. First it defines the variables needed in the script:
image

In the Start() function it stores the bobbers position; it gets component for the cast bar -slider component(will be talked about more in next chapter) and the hooks rigid body.
image

There are currently 4 methods inside the class. 3 that control the casting system, and one IENumerator method, that is intended to pass information to the UI system for the cast bar.

The first Method, StartCast, is called based on the player using the input system (events):
image

The method checks if the player has casted, and conditions whether space key is pressed. It stores the start time of the key down; it sets the cast bar slider component active on the screen and starts the coroutine for the cast (for the GUI cast bar).
On the .canceled if-statement it checks when the space-key is released. It stores the time from that moment and does a calculation for the velocity of the bobber and launches the bobber in that direction. The holdTotal variable makes sure, that the player cannot launch the bobber out of the screen. Also, it hides the cast bar and puts the haveYouCasted -variable in a false value, so that the player can cast again (if this is true, it means the bobber is in the air, and player cannot cast midair)

The next method ResetCast, is triggered when the player hits the ResetCast keys defined in the input action mapping.
image

It first checks if the bobber is staying still and if it is, you can cast again. If it’s still moving, you cannot cast (stated by the Debug.Log). The “bobberScript.DestroyHookAndSwapActionMap();” syntax calls a method from the BobberScript.cs. Which has the following method:
image

The BobberScript.cs has a collision method, that compares when the bobber object hits the water surface:

image
image

That includes the instantation of the hook object (Aleksandars part), but for my work, it also has the action map switch. The logic behind this is, that when the bobber hits the water surface, the keybinds can partially stay the same, but the functionalities change.
image

The logic is that when the cast is reseted in the PlayerController, the method is called, the bobber and the cast is reset, and the hook generated is destroyed. It changes the action maps (the controls) back to initial state.
The 3rd method is a WIP, meant to have functionality, when the player has casted the bobber, the bobber the water plane and the hook is generated, then the hook starts to fall. The idea is that this method is called when the player presses the StopHook -keys, that would make the hook stop falling at a certain depth. But as seen from the screenshot, it’s still in progress:

image

The IEnumerator method SliderChargeUp() is called to do a while loop, which is then updated to the visual GUI, to let the player see, how long he has held the cast key and how far the cast will approximately end. This is purely visual though and doesn’t affect the other system mentioned above.
image

Canvas and cast bar

I created the Canvas for graphical elements on the hierarchy. This was needed in order to have visual representation of the cast bar.
image

The canvas itself was setup to have screen space – overlay render mode, and to scale with reference resolution of Full HD(1080p). So, in the case of user being able to scale the game window, the elements would also rescale accordingly.
image

The canvas also holds the Slider, that was mentioned in the IEnumerator and PlayerController methods a few times. This is a slider object on the hierarchy, and it looks like this on the screen:

image
image

The sliders activate state is deactive by default. This means, that using the code shown previously, the slider will only show when the space key is pressed. The time calculation is sent from the code to the value of the slider, which increases the longer you hold the space key:
image

LineRender for the fishing line

The visual fishing lines are actually made with the LineRenderer component.
image

The actual logic is modified inside three different classes, which the LineController is base class, and HookLine and BobberLine inherit from this class. The logic is that the LineController does the calculations for the LineRenderer length and position. And the two other classes define the starting and ending points of the line.

image

The logic between HookLine and BobberLine had to be different. BobberLine gets the start and endpoints from the inspector references and stores them in the array for the SetUpLine method (in LineController) to use.
image

The previous method however couldn’t work with the line from the Bobber to the Hook because the hook is not initially in the scene-view and is instantiated from a prefab. So, this was a problem, because the reference couldn’t be made in advance, so that inspector couldn’t be utilized for this.

I did the following to solve this:

image

In the HookLine script the start position (so where the bobber is and where the hook starts falling from) is gotten by getting the “Bobber” named GameObject from the hierarchy (yes, only once because of the resource-heavy Find-function), and then stored in the variable. This way we get a reference for the start of the line and the endpoint is the hooks own Transform values.

My issues from our Github (as of writing this document):

image

@TemkaUwU
Copy link
Contributor

TemkaUwU commented Oct 7, 2023

Introduction

Aleksandar Hristov – I am a fresh high school graduate with extremely limited unity experience mostly as an artist. I studied C# in high school but never learned to use it in the real world. My role in the project is very minor and I have been doing small bits of code wherever I can.

Completed tasks

I made the hook object spawn and go down by modifying the bobber script

image
I just spawn the hook object 1 float lower than the bobber when it hits the water plane. Then gravity takes care of it going down.
image

In-Progress tasks

Stopping the hook from going out of bounds 

Setting the hook into position 

Reeling back the rod on command 

Creating music and SFX for the game 

(optional) Creating assets to replace the unity store ones 

@jaakop
Copy link
Contributor Author

jaakop commented Oct 9, 2023

Assignment 2 is submitted. Closing this issue.

@jaakop jaakop closed this as completed Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants