Game Development :Land of Sol journey

Introduction:

This blog is for updates about the Project. This Project is made for One of the modules at Kingston University. A blog containing a chronicle of the timeline of the project and Individual Contributions to the project, showcasing the programming and design aspects of the project.

Project Environment: 

The project is made with  Unity. This project uses a photon server which is essential for creating multiplayer games. 

Early stage:

Connecting and setting up players in photon:

Photon Connected two players setting up the photon for the project. Setting up Pun 2 It was required to log in from the photon server and then connect the Pun2 wiz in unity with a unique id. Each project has its unique ID. Using the photon server We were able to create an instance for the server. 
When a player joins the room they have their unique local ID and every player must have a Photon View component as this component acts as the connecting for the server. Acting as a conduit between the client and the server, Photon View serves as the linchpin of the game's multiplayer infrastructure. By attaching a Photon View component to each player object, the game establishes a direct line of communication that enables real-time synchronization of actions and events across all connected devices.

My contribution to the connecting photon server was to make the character selection so each player could choose their prefab. Created basic movement script for the cubes in tried in the multiplayer. No RCP calls were required for synchronization as photon view already does that synchronization with other clients. 

Creating map early stages:


Early stages of the map just created a map with unity terrain and added tree prefabs.

Improvements on character movement script: the character movement script Has an issue as the gravity is not working even though it has a Rigidbody component and the character unable to go backward. Besides that camera and rotation of the character towards the mouse curser are working. 

My contribution to improving the script I changing the logic for the movement rather than using rigid body force I used the Character controller component 


It starts by capturing player input for horizontal and vertical movement. The script then calculates a normalized direction vector based on the input, ensuring consistent movement speed regardless of direction. Smooth rotations are applied to orient the character in the desired direction, enhancing the responsiveness of player control.

Implementing gravity directly in the movement script, as shown in, offers simplicity, efficiency, predictability, and flexibility compared to using a Rigidbody component for character movement. This approach provides greater control over the character's behavior. Adding a rigid body component and having a character controller component same time raised a lot of issues so using physics gravity was the best solution. 


 At the Update() function lies a conditional check to determine if the current instance of the game object belongs to the local player. This ensures that gameplay logic is executed only for the player who owns the object, optimizing performance and preventing redundant processing for remote players.

Updating of the joining lobby:

As designer decided to make the players have their choice of prefabs. So once they join in the room and then it creates an instance for the room and whoever joins the room first becomes to host and other players become the clients. 

This is a simple UI that lets choose between prefabs and players get chosen characters. 

The Instance property within the CharacterSelection script embodies the singleton design pattern, ensuring that only one instance of the CharacterSelection class exists within the scene. Its implementation revolves around a static property Instance, which, upon invocation, first checks if the instance variable is null. If it is, the property attempts to locate an existing instance of CharacterSelection within the scene using FindObjectOfType. Should such an instance not be found, the property instantiates a new GameObject named after CharacterSelection, attaches a CharacterSelection component to it, and assigns it to the instance. Ultimately, the property guarantees that there is always a single, accessible instance of CharacterSelection, streamlining interaction and cohesion across various components and systems within the game environment. This pattern enhances code clarity, and organization, and facilitates consistent access to the CharacterSelection functionality.


The SelectCharacter method logs the call and then utilizes Photon networking to synchronize the chosen character across all players while providing optional UI element deactivation for enhanced user experience. This calls RPC for the function setselectedcharacter which gets the player ID (which is the local id for the player )  and stores the character index and when every player chooses the there character they get an Instantiate the player in the map.


Spawning the players after they chose the characters:

based on values saved in the dict the players get instantiated in the server.


Updates on the map:

Added a flying island that connects the terrain and acts as a bridge between the island and the terrain added colliders for the base of the flying island and this acts spawn point for the players when they instantiate from the server.


  Water shader: Made water shader for the realist water and improved the visuals 


Random Object Placement: 

Objects need to be placed randomly which gives the change of the map every time the game is played and the Little Devil has to be randomly so they randomly spawn within the outline. All objects are placed in an array that spawned in the map but the little devil just spawns one per area as they are resisted and the objects are placed randomly so each time the map is generated they are different always.


Start Method: The Start() method is a Unity callback function invoked when the script starts executing. Within this method, several checks are performed to ensure the script's prerequisites are met before proceeding with object placement. If the script is not running on the master client in a multiplayer environment, or if essential variables like m_gameObject and shapeControlPointsArrays are not properly set, error messages are logged, and the execution halts. Assuming all prerequisites are met, the method proceeds to spawn objects based on random positions within the defined shapes.



Here we are going to get random positions from each object randomly and make them chose to spawn


portals: portals act as the teleporting option from one place to another place with quick traveling and the other portals just have one collider and every time the collider gets triggered the player travels to the other side of the transform of the other portal.

updated menu: The updated menu has a player name and also has the menu here and camera rotate 

towards the center of the rock and it makes look nicer and used unity splines for the track of the camera.



Character selection:

Character selection every player has to select player own choice prefab

Need to create a singleton to make sure even though the scene changes the values and character and selected prefabs



Here are the functions selected character takes gets calls the function passes RCP through all the clients and gets the local player. The actor number is the ID for the local player and after that set character is going to be pushed into the directory which has the ID and index and is now based and pushed to the spawned prefab.



spawn players with their selected prefabs and these prefabs are selected before the getselectedcharacterindex according to that they spawn the player and all these values are saved in
dictionary and with photonnetwork.instaniate on the server and on the selected transform it takes empty object position and spawns player.




These are non- NPC characters in the game they act as chests when every character/player and the 2d puzzle spawn and when they are over it they spawn the artifact. The non-NPC character would move around with given radius.



This is the movement script for the noncharacter when they spawn they take a random position within the given radius and move towards it and also make sure they get cords this function runs in the update so they are always run in the update function. also have the collider which acts detection for the players and when every player comes in the range the canvas presses a button to get actives. 



2d puzzles: 
improvements on the 2d puzzles where they can be random always and also have a timer when they are on the things if they win the game they get the artifact which the artifact can be used for the alter.
There is a dynamic way of getting access from the puzzles NPC script which this script is attached to the non-player character .





The puzzles in the scene are placed with tags called puzzles and these are from the scene reference from the scene to the non-player character. now all the puzzles are in the list and get random always and select one.

now all the scripts for puzzles also get the reference from the script name his function where it searches for the in the child object and then finds the scriptname in and gets all the reference and the script with that object has tag with same name as the script so it find it.


There an interface called ipuzzlecompoenent which gets winning and losing conditions from the puzzle scripts and gets the reset function is which has a common name this way the puzzle gets reset all the way.


with the unity spline using and using spline animation we added the extra effect of the bird flying around the map.



2d puzzles have a timer whenever the player gets a puzzle pops up the timer starts with the timer. for this game, they have to align all the lines together. they consider as a win if they are not doing in time it is considered as losing.


abilities:
invisibility:this character does not them self have the mesh component so for them to make invisibility
so all characters have mesh and different components so there is funtion first it takes photonview component and takes the first child objects 6 of them and put them in the list and make the disable for period and uses RCP calls to make sure that they get disabled when they are on in the server which makes the things possible for them to become invisibility (this works in game)




steal:
for the steal used by Raycast and Raycast checks if the objecting hitting it would be the player then takes the player tag and gets his artifact the starting the ray cast was not working as the charactercontroller is not begin shared with other clients so the clients does not have the charactercontroller or collider so had to change the character controller which makes the rcp and this that would have the collider and this collider has this thing when they have hit the player then it just gets the character variable. 


frozen ability this works for multiple here the player ray cast and checks for the enemy and this enemy also checks if the player has hit the enemy if they did then they will be the enemy and this makes the disable the collider of that enemy for 5 secs which makes them disable and call rcp. this updates in the photon server and makes sure it is synchronized across the server.










 


Comments