In this week, I started to work on the programming for my group project. I focused on making a movement script, using the Cinemachine package for camera movement, and refining that movement script through making a basic level using ProBuilder.
Making a basic movement script.
To begin with, I created a ball object in Unity, I researched ball movement for Unity and I followed a YouTube video to create a basic movement script for the player, with 1 change, since I was familiar with the new Input System, I used that here instead of the old Input System that the video used (Youtu.be. 2025). The way it worked was this, I would add a PlayerInput component to the player, which I can then use to make a InputAction file, where I would store all of the player inputs for the game, and then I would hook up the relevant functions (movement, jumping) to the corresponding Inputs on the PlayerInput component. This has several benefits compared to the old InputSystem, that being cleaner code, and easier editing of the players inputs.
Adding a jumping mechanic to the player was also easy. What I did here was add a jump action to the InputAction file, and then in the PlayerMovement script, when the player presses the jump button, add a force upwards using a new Vector2 that includes a new variable called JumpSpeed.
At this point, I also added packages that I owned through the Package Manager, and one of the packaged I added was a model of a muscular human frog that I bought for a project that I quickly scrapped. This wasn’t to be used for the game, it was just to test out the player character.
Camera Movement
The next thing I decided to focus on was the camera movement. I did this by following a Brackey’s tutorial on third person movement (Youtu.be 2025b). I didn’t need most of the video since I had already implemented code to get the player to move, but the first couple of minutes were important, as Brackey’s demonstrated how to easily add camera movement to the player. The first step was to add the Cinemachine module, the second was to add a CinemachineFreeLook camera to the game, and to add the player to the LookAt and Follow slots on the Third Person Camera GameObject that was added when I put in the FreeLook camera.
Making a simple level using ProBuilder, refinement and code changes.
I decided to make a level using a level modeling tool called ProBuilder. I made a new scene in Unity to contain this level, with the intention of creating a basic level that I would use to refine the movement code.
Within this movement code, I added a maze like structure where the player has to move around to get to a ramp, which then is used to test the physics. For kicks and giggles, I added an Eames Lounge Chair model I found free from Sketchfab. I also used ProBuilder to create some blocks for the player to knock over, placing the models on top so that they would fall to the ground when the player hit the blocks. I also had a Unity package which contained a buff frog humanoid that I threw in the scene. I would eventually remove both elements as they were taking too much performance.
One of the bits of feedback I got was to increase the amount of gravity for the ball player, so that they fall down to the ground like a marble would. I had 2 options to do this, via the Unity settings to increase the gravity in general, or via code. I chose the code route, so it only affected the player. It was fairly easy to implement, since I already had a GroundCheck function, and would go like this: if the player was not on the ground, add a force to the Rigidbody downwards by a number determined by a float called gravityScale, multiplied by vector2.down.
During this point, I also decided to make some changes to the movement script, since it didn’t use Time.DeltaTime yet, when I build it to WebGL, the player would not move as fast as in the editor at peak performance, yet when my MacBook Air, which doesn’t have a fan, got hot, that would also affect the performance and caused the ball movement to slow dramatically down.
The way I fixed this was by moving some parts of the code around, and dramatically bumping up the values of some of the variables I was using. Since I was using the New Input System, I had a function called OnMove that captured the player’s input variable, and would set a CanMove bool to true. On the FixedUpdate function, I would use that data to add a velocity to the player’s rigidbody, multiplied by time.fixedDeltaTime (fixedDeltaTime because it is in the FixedUpdate function, not the Update function).
The final 2 changes I made to the game relate to the camera. One of which is when the player’s camera is overlapping with objects, which causes the camera to go through said objects. I fixed this by watching the Brackey’s video further, where I found a CinemachineCollider modifier that I can use to make the camera move forward when the player’s camera overlaps with objects.
The second change here is making the player’s camera move according to the camera. This was tougher than the first, as I had to do some research and trial and error. But how I did it was this, in the FixedUpdate, I got the camera’s transform movement, then I multiplied it with the moveSpeed and time.fixedDeltaTime, used that to set a new variable called movementForce, and then used movementForce to add to the players Rigidbody velocity.
private void FixedUpdate()
{
if (_canMove)
{
Vector3 movement = _cameraTransform.right * _direction.x
+ _cameraTransform.forward * _direction.y;
movement.y = 0f;
movementForce = movement * (moveSpeed * Time.fixedDeltaTime);
_rb.velocity += movementForce;
}
else
{
movementForce = Vector3.zero;
}
if (!IsGrounded())
{
_rb.AddForce(Vector3.down * (gravityScale * Time.fixedDeltaTime));
}
}
Meetings
It was at this stage where the Friday meetups started to fall apart, by the following week we didn’t do any meetings on Friday at all, as attendance was already low to begin with and there wasn’t that many topics of discussion in these meetings. This correlates with the experience Esi has been having with teamwork as described in her blog (Wsagames.com. 2025).
Conclusion
For the following week, I will continue to work on the movement code, refining it more and getting more feedback so I could improve the code, and the game overall.
References
Wsagames.com. (2025). Week 1 – 4 Meetings – Kinetic Panic. [online] Available at: https://year2.wsagames.com/kineticpanic/2025/02/20/week-1-4-meetings/ [Accessed 2 Apr. 2025].
Youtu.be. (2025a). Available at: https://youtu.be/fESM_UIg1rA?si=73OH6pkPrBviZU5m [Accessed 2 Apr. 2025].
Youtu.be. (2025b). Available at: https://youtu.be/4HpC–2iowE?si=pY-joYGiSdPKVR0X [Accessed 2 Apr. 2025].