0% found this document useful (0 votes)
6 views3 pages

Game Dev

The document covers various aspects of game development using Unity, including debugging, Rigidbody physics, player movement, camera following, and collision detection. It provides solutions for common issues like frame rate dependency and slow controls, as well as tips for managing player interactions with obstacles. Additionally, it discusses UI elements for displaying points and the importance of proper lighting settings in the game environment.

Uploaded by

skthisside2850
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Game Dev

The document covers various aspects of game development using Unity, including debugging, Rigidbody physics, player movement, camera following, and collision detection. It provides solutions for common issues like frame rate dependency and slow controls, as well as tips for managing player interactions with obstacles. Additionally, it discusses UI elements for displaying points and the importance of proper lighting settings in the game environment.

Uploaded by

skthisside2850
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Video-3

Debug.Log(“….”); -> prints to console

Public Rigidbody rb;

Rb.useGravity=false;

Rb.AddForce(x,y,z); (called once when we start the game)

In update, it will happen for the rest of the game -> rate of updation depends on frame rate (faster
computer will run faster than a slower computer)

Soln: Rb.AddForce(x,y,z*Time.deltaTime); (inv proportional to frame rate)

FixedUpdate instead of Update for physics related things

Video-4

Rigidbody -> constraints-> freeze position/rotation

But the above method wont be good in case the object collides with another object

Soln: physics object needed (controlling friction)

Create->physic(s) material-> set static and dynamic friction to zero and drag it to ground

Use of variables:

Int (whole no), float, string, bool (500f for floats is advised)

To edit variable in inspector: public <type> <data> (inspector is on left side of unity window)

Player input -> if statement

if (Input.GetKey(“d”))-> checks if user pressed ‘d’ on keyboard

put appropriate addforce commands to have exhibit necessary changes whenever use performs
certain actions

Video-5: Following Player Movements By The Camera (Multiple ways)

1. Parenting camera: Dragging camera under player


But camera rotates when player rotates as well (looks weird)
soln:
2. Follow position of the player:
Newscript created (FollowPlayer) (camera)
Transform-> data type (link to player’s position, rotation,etc.)
Then public Transform player; drag player onto the inspection at main camera
In update: Debug.Log(player.position) -> gives current x,y,z coordinates of the player
transform-> refers to current object (object the script is sitting on)
transform.position-> position of our camera
transform.position = player.position; -> but it follows centre of the player
desirable: (maybe) a bit behind and a bit above
soln: offset: y=1, z=-5
Vector3-> data type (stores 3 floats)
public Vector3 offset;
transform.position = player.position+offset;

Video-6: Collisions

New script: PlayerCollision

void OnCollisionEnter(Collision collisionInfo)-> called whenever the object (here,player) collides with
some object
that object can be dragged into Player Collision script as long as it is rigid body and has box collider

create-> material -> drag onto newly created obstacle

rigidbody: add component-> physics-> rigidbody

maybe increase mass(2)

Debug.Log(collisionInfo.collider.name);

One utility:

if(collisionInfo.collider.name == "Obstacle")

Debug.Log("We hit an obstacle!");

Using tags to refer instead of names: inspector-> add tag

if(collisionInfo.collider.tag == "Obstacle")

Debug.Log("We hit an obstacle!");

To avoid the player from flying away after hitting an obstacle:

public PlayerMovement movement;

if(collisionInfo.collider.tag == "Obstacle")

movement.enabled = false; //disables Player Movement if an obstacle is hit

Video 7: Making a Video Game

Create prefab of obstacle: drag obstacle object to the project panel (to use multiple objects of same
type)

Changes-> click apply to apply to all obstacles

Problem: slow controls due to problem with movement script

(momentum builds up over time)


ForceMode.VelocityChange and less sideway force (approx. 100 would do)

Increase drag

And so amp up forces

window > Rendering > Lighting > Environment for fog(so that next obstacles are not visible)

Video 8: Coins/Points in Game

For those who don't have their starting position at Z 0, I made something to make it easier:

1. Add a public float variable called "initialZ"

2. Add a void Start() method (if you removed it)

3. Inside it, add "initialZ = player.position.z" (replace "player" with what you named your player)

4. On the top of the Update() method, add the following: "float newZ = plr.position.z - initialZ;"

5. Replace "player.position.z.ToString()" (where you change your text) with "newZ.ToString()"

or anyone following this tutorial in 2021 or until they change it, you can add text from
GameObject(at the top) -> UI -> Text

If you are using Text Mesh Pro, then disable "Wrapping" instead of enabling "Overflow"

If you have new version unity then lighting is set after GAME OVER is by these steps 1) click on
Window 2) click on Rendering 3) click on Lighting 4) Then click on Generate Lighting which is present
in Light Probe Visualization 5) Done. I hope this helps

Ensure that your sampling rate is at least 10 times the carrier frequency. Since your carrier is 200 kHz,
a sampling rate of 2 MHz or higher is recommended. This will help in accurately capturing the high-
frequency variations of the FM signal for a smooth derivative.

You might also like