Complete the code to manually apply gravity to a Rigidbody component in Unity each FixedUpdate.
rigidbody.[1] += Physics.gravity * Time.fixedDeltaTime;In Unity, to manually simulate realistic gravity in FixedUpdate, you add Physics.gravity * Time.fixedDeltaTime to the Rigidbody's velocity property.
Complete the code to add a force to a Rigidbody to simulate a push.
rigidbody.AddForce([1] * forceAmount);Using Vector3.forward applies force in the forward direction, simulating a push.
Fix the error in the code to correctly simulate friction on a Rigidbody.
PhysicMaterial material = new PhysicMaterial();
material.dynamicFriction = [1];
rigidbody.sharedMaterial = material;The dynamicFriction property expects a float value like 0.5f, not an integer or string.
Fill both blanks to create a dictionary that maps object names to their Rigidbody mass if mass is greater than 1.
if (rigidbody.[2] > 1f) { var heavyObjects = new Dictionary<string, float> { { [1], rigidbody.[2] } }; }
We use the object name as a string key and the Rigidbody's mass property as the value.
Fill all three blanks to create a dictionary comprehension that maps object names to their velocity if velocity magnitude is greater than 2.
if (rigidbody.[3].magnitude > 2f) { var fastObjects = new Dictionary<string, Vector3> { { [1], rigidbody.[2] } }; }
The dictionary key is the object name string, and the value is the Rigidbody's velocity. The condition checks velocity magnitude.