WEEK3 |Unity 2D Physics | Moving GameObject

2
GameObject | Unity Component | RigidBody2D
5
Physics 2D | Gravity
6
Project Settings | Physics 2D
8
Physics2D
10
Physics2D Setting | Gravity
9
RigdBody2D | GetComponent | RigidBody2D.AddForce

GetComponent

  • we can get other components that are attached to the same Game Object this script is attached to by calling “GetComponent” and we put that component into a variable

RigidBody2D.AddForce

  • public void AddForce(Vector2 force, ForceMode2D mode = ForceMode2D.Force);
  • ForceMode2D
    • ForceMode2D.Force – Add a force to the Rigidbody2D, using its mass.
    • ForceMode2D.Impulse – Add an instant force impulse to the rigidbody2D, using its mass.
11
Script Attached
12
GameObject Moving