0
0
Unityframework~10 mins

Rigidbody2D component in Unity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add a Rigidbody2D component to the GameObject.

Unity
gameObject.AddComponent<[1]>();
Drag options to blanks, or click blank then click option'
ATransform
BCollider2D
CRigidbody2D
DSpriteRenderer
Attempts:
3 left
💡 Hint
Common Mistakes
Using Collider2D instead of Rigidbody2D.
Trying to add Transform component which already exists.
2fill in blank
medium

Complete the code to set the Rigidbody2D's gravity scale to zero.

Unity
Rigidbody2D rb = GetComponent<Rigidbody2D>();
rb.[1] = 0f;
Drag options to blanks, or click blank then click option'
AgravityScale
Bmass
Cdrag
DangularVelocity
Attempts:
3 left
💡 Hint
Common Mistakes
Setting mass instead of gravityScale.
Using drag property which affects resistance, not gravity.
3fill in blank
hard

Fix the error in the code to apply a force to the Rigidbody2D.

Unity
Rigidbody2D rb = GetComponent<Rigidbody2D>();
rb.AddForce([1]);
Drag options to blanks, or click blank then click option'
Anew Vector3(10, 0, 0)
Bnew Vector2(10, 0)
Cnew Vector4(10, 0, 0, 0)
Dnew Vector(10, 0)
Attempts:
3 left
💡 Hint
Common Mistakes
Using Vector3 or Vector4 which are for 3D or 4D vectors.
Trying to use Vector which does not exist.
4fill in blank
hard

Fill both blanks to create a Rigidbody2D and set its body type to Kinematic.

Unity
Rigidbody2D rb = gameObject.AddComponent<[1]>();
rb.[2] = RigidbodyType2D.Kinematic;
Drag options to blanks, or click blank then click option'
ARigidbody2D
BCollider2D
CbodyType
DgravityScale
Attempts:
3 left
💡 Hint
Common Mistakes
Using Collider2D instead of Rigidbody2D.
Setting gravityScale instead of bodyType.
5fill in blank
hard

Fill all three blanks to get the Rigidbody2D, set its mass, and apply an upward force.

Unity
Rigidbody2D [1] = GetComponent<Rigidbody2D>();
[1].[2] = 5f;
[1].AddForce(new Vector2(0, [3]));
Drag options to blanks, or click blank then click option'
Arb
Bmass
C10f
DgravityScale
Attempts:
3 left
💡 Hint
Common Mistakes
Using gravityScale instead of mass.
Forgetting to use the same variable name consistently.