UNITY | PROJECT | 2D PlatFormer | 1. Project Set Up

2
Importing Sprites

 

3
Cutting Sprites

 

4
Creating “Ground”
  • Add “Box Collider” to “Ground”

 

5
Adding “Player”
  • Add “Box Collider” to “Player”
  • Add “RigidBody2D” to “Player”
7.1
Adding “PlayerControl” Script
7.2
Physics Working

 

8
“PlayerControl” Script
  • Claim variable for Player movement
    • playerSpeed
    • facingRight as flag
    • playerJumpPower
    • movementX
  • in “Update()” method
    • get input to move horizontally by using “Input.GetAxis()”
    • get “RigidBody2D” component by using “GetComponent()”
      • call “velocity” propery to move “Player” with continuous input
    • create “if Statement” for Player’s movment
      • when pressing left and facing right
        • activate “FlipPlayer()” method
      • when pressing right and facing left
        • activate “FlipPlayer()” method
    • Create a Function, “FlipPlayer()”,
      • set the flag, “facingRight” to opposite
      • get the “localScale” property
        • multiply -1 to reverse the direction
      • Don’t forget to update “localScale”
10.2
Player Moving
9
“PlayerControl” Script
  • Create a function, “Jump()’,
    • use “AddForce()” to give force upwards to “Player”
  • in “PlayerMove()” method,
    • when “Jump” button is pressed, activate “Jump()” method

 

10.1
Input Manager

 

10.3
Player Jumping too high

 

11.1
RigidBody2D | Linear Drag | Gravity Scale
  • Set “Linear Drag” 0 to 1 to prevent “Player” from jumping too much
  • Set “Gravity Scale” 0 to 10 to prevent “Player” from jumping too much

 

11.2
Player Jumping
  • Player jumps normally but still it can jump multiple times in the air

UNITY TUTORIAL | PHYSICS | 3D Physics | Adding Physics Forces

2
GameObject with RigidBody | Mass | Drag
3
AddForce() | OnMouseDown() | UseGravity
4
AddForce | ForceMode
5
RigidBody | Mass & Drag changed
addingForce
AddForce() | OnMouseDown()
drag
AddForce() | OnMouseDown | Drag increased

UNITY TUTORIAL | PHYSICS | 3D Physics | Colliders as Trigger

UNITY TUTORIAL

PHYSICS | 3D Physics | Colliders as Trigger

 

collider-as-trigger1.png
Trigger | BoxCollider | Is Trigger

 

trigger1
Is Trigger
322.png
Trigger | BoxCollider | CollisionDetection script
4
OnTriggerEnter() | OnTriggerStay() | OnTriggerExit()
5
Falling Object | RigidBody
trigger2
OnTriggerEnter() | OnTriggerStay() | OnTriggerExit()
6
Hovering​ Script
7
Collider.attachedRigidBody | AddForce() | ForceMode.Acceleration()
hovering1
Hovering Simple
hovering2
Hovering Force Changing
8
Freeze Position
hovering3
Hovering with FallingObject Frozen

 

UNITY TUTORIAL | PROJECT | Roll a Ball | 2. Moving the Player

Roll a Ball

Moving the Player

2
Adding RigidBody
3
Added RigidBody
5
Using RigidBody with Script
6
MovePlayer Script | RigidBody | FixedUpdate | Input.GetAxis | AddForce
7
Adding Script as Component
8
Adding Speed as Public Variable
9
Public Value in the Inspector
10
Chaing Value directly in the Inspector

ezgif.com-video-to-gif-2.gif

117.png
Chaing Value directly in the Inspector

ezgif.com-video-to-gif-3

12