Physicalizing an Entity
The entity function
Physicalize enables physics on a specific object by using a proxy to simulate it. The proxy object is a simplified version of the geometry model used in the game. In order to allow the CRYENGINE to calculate physically correct movement and collisions, a minimal number of properties have to be set.
Density or the
Mass property has to be specified. The other value is automatically computed using the relationship mass = density * volume.
Entities can be physicalized as several types by changing the type of the PhysicalizeParams, for example by changing it to StaticPhysicalizeParams or LivingPhysicalizeParams. More information about the various physics types can be found on the Physical entity types page.
The common way for moving an Entity within CRYENGINE is to specify its physical behavior, so the engine moves the Entity accordingly. This can be done by setting the properties of the
PhysicsEntity of the Entity.
Velocity only has to be set once for objects flying in a straight line. This is ideal for projectiles fired by weapons such as the default gun in Sydewinder.
However, any object with variable speed or an object that may change its direction periodically needs to be updated whenever its required.
Collision detection is an essential part of the Sydewinder game. It is used to handle projectiles hitting the player and enemy ships, or detecting if the level geometry is hit. In Sydewinder one or both objects involved in a collision will be destroyed, but objects not destroyed can move along their original path.
In order to react to collisions an Entity can override the
OnCollision method to receive a message whenever a collision with that Entity occurs. If a collision occurs, the method will be called with a
CollisionEvent which has more information about the collision, such as the entities involved in the collision. For example, for Sydewinder's
Player class we check if a
Tunnel or a
DefaultAmmo Entity is hit, and handle the collision based on the type.