Rock slide

In the wrecking ball recipe, we looked at using a RigidBodyEx sphere model to use as our wrecking ball. In this recipe, we will use that same RigidBodyEx as the basis for a rock analog and clone it a few times so we can build our landslide.

Getting ready

  • You should have completed the Wrecking ball recipe
  • Open My_Level.cry within the Sandbox

How to do it...

  1. Begin by creating a terrain hill about 30 meters in height with a slope of about 35-45 degrees.
  2. Copy and paste the house that was used from the Wrecking ball recipe and place it at the bottom of the hill.
  3. Next, select the sphere RigidBodyEx from the Wrecking ball recipe and clone it and place it more than half way up the hill. Also, change the following properties on the sphere:

    Resting = False

  4. Next, clone the RigidBodyEx five times and stack them on the hill like a carton of eggs. Make sure they are tight and are also touching each other (this will make sure they all get activated physics when triggered).
  5. Last, place the breakable brush fence object Objects/library/barriers/fence/wooden/wooden_fence_120_400_a.cgf under the bottom RigidBodyExs. Be sure that the fence is also touching the RigidBodyExs.
  6. Your setup should look like the following screenshot:
    How to do it...
  7. The next time the player enters the level and destroys the fence placed with something like a rifle, the RigidBodyExs will activate its physics and slide/roll down the hill and destroy the house as shown in the following image:
    How to do it...

How it works...

The RigidBodyEx entity is an extension to the BasicEntity that reacts more realistically with other entities and water. The attached object can break other objects and has more options as to when and how to react.

There's more...

Here are some additional properties that can be applied to the RigidBodyEx class of the entity.

Physics properties

The physics properties are as follows:

  • ActivateOnDamage: This tells us that an inactive rigid body (RigidBodyActive=0) should be activated on damage.
  • CanBreakOthers: This is True if the entity can break joined objects by colliding with them (provided they overcome the strength limit). Basic entities have this flag off unconditionally.
  • Density: (Density = Volume / Mass) This affects the way objects interact with other objects and float in the water (they sink if their density is more than that of the water). Note that both mass and density can be overridden in the asset.
  • Mass: (Mass = Density * Volume) This is the weight of the object (the density of the object multiplied by its volume).
  • Physicalize: If not set, the object will not be taken into account by physics.
  • PushableByPlayers: When set, the object can be moved by the player.
  • Resting: When True, the object's physics are asleep on start. When False, the physics are activated until kinetic energy falls below the sleep_speed limit and is put to sleep again (refer to sleep_speed shown further).
  • RigidBody: False means a static entity; True means a simulated rigid body. Note that a rigid body can still behave like a static entity if it has mass 0 (set either explicitly or by unchecking RigidBodyActive). The main difference between these rigid bodies and pure statics is that the physics system knows that they can be moved by some other means (such as the Track View) and expects them to do so. This means that objects that are supposed to be externally animated should be mass-0 rigid bodies in order to interact properly with pure physicalized entities.
  • RigidBodyActive: This property indicates that the object is a rigid body, but initially it is immovable. Instead, it can be activated by an event later.

Simulation properties

The simulation properties are as follows:

  • Damping: (0..3) This sets the strength of the damping on an object's movement. Most objects can work with 0 damping; if an object has trouble coming to rest, try values like 0.2-0.3. Values of 0.5 and higher appear visually as overdamping. Note that when several objects are in contact, the highest damping is used for the entire group.
  • FixedDamping: (true/false) When true, this object will force its damping to the entire colliding group (use it when you don't want a particular object being slowed by a highly damped entity, such as a dead body).
  • max_time_step: (0.005..0.1) This sets the maximum time step the entity is allowed to make (defaults to 0.01). Smaller time steps increase stability (can be required for long and thin objects, for instance), but are more expensive. Each time the physical world is requested to make a step, the objects that have their maxsteps smaller than the requested one, slice the big step into smaller chunks and perform several sub steps. If several objects are in contact, the smallest max_time_step is used.
  • sleep_speed: (0.01..0.3) If the object's kinetic energy falls below some limit over several frames, the object is considered sleeping. This limit is proportional to the square of the sleep speed value. A sleep speed of 0.01 loosely corresponds to the object's center moving at a velocity of the order of 1 cm/s.

See also

  • The Wrecking ball recipe
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.197.213