Learning C# by Developing Games with Unity 2021 by Harrison Ferrone

Learning C# by Developing Games with Unity 2021 by Harrison Ferrone

Author:Harrison Ferrone
Language: eng
Format: epub
Tags: COM051310 - COMPUTERS / Programming Languages / C#, COM012040 - COMPUTERS / Programming / Games, COM012000 - COMPUTERS / Computer Graphics
Publisher: Packt
Published: 2021-10-27T12:11:41+00:00


Figure 7.6: Rigidbody component in the Inspector pane

Collider components, which determine how and when GameObjects enter and exit each other's physical space or simply collide and bounce away. While there should only be one Rigidbody component attached to a given GameObject, there can be several Collider components if you need different shapes or interactions. This is commonly referred to as a compound Collider setup:

Figure 7.7: Box collider component in the Inspector pane

When two Collider components interact with each other, the Rigidbody properties determine the resulting interaction. For example, if one GameObject's mass is higher than the other, the lighter GameObject will bounce away with more force, just like in real life. These two components are responsible for all physical interactions and simulated movement in Unity.

There are some caveats to using these components, which are best understood in terms of the types of movement Unity allows:

Kinematic movement happens when a Rigidbody component is attached to a GameObject, but it doesn't register to the physics system in the scene. In other words, kinematic objects have physics interactions but don't react to them, like a wall in real life. This is only used in certain cases and can be enabled by checking the Is Kinematic property of a Rigidbody component. Since we want our capsule to interact with the physics system, we won't be using this kind of motion.

Non-kinematic movement is when a Rigidbody component is moved or rotated by applying force rather than manually changing a GameObject's Transform properties. Our goal for this section is to update the PlayerBehavior script to implement this type of motion.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.