Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds

CryENGINE 3: Fun Physics

Save for later
  • 4 min read
  • 12 Jul 2011

article-image

CryENGINE 3 Cookbook


cryengine-3-fun-physics-img-0

Over 90 recipes written by Crytek developers for creating third-generation real-time games

Low gravity


In this simple recipe, we will look at utilizing the GravityBox to set up a low gravity area within a level.

Getting ready

  • Have Sandbox open
  • Then open My_Level.cry

How to do it...

  1. To start, first we must place down a GravityBox.
  2. In the RollupBar, click on the Entities button.
  3. Under the Physics section, select GravityBox.
  4. Place the GravityBox on the ground:

cryengine-3-fun-physics-img-1


Keeping the default dimensions (20, 20, 20 meters), the only property here that we want to change is the gravity. The default settings in this box set this entire area within the level to be a zero gravity zone. To adjust the up/down gravity of this, we need to change the value of gravity and the Z axis.

To mimic normal gravity, this value would need to be set to the acceleration value of -9.81. To change this value to a lower gravity value, (something like the Moon's gravity) simply change it to a higher negative value such as -1.62.

How it works...


The GravityBox is a simple bounding box which overrides the defined gravity in the code (-9.81) and sets its own gravity value within the bounding box. Anything physicalized and activated to receive physics updates will behave within the confines of these gravitational rules unless they fall outside of the bounding box.

There's more...


Here are some useful tips about the gravity objects.

Uniform property


The uniform property within the GravityBox defines whether the GravityBox should use its own local orientation or the world's. If true, the GravityBox will use its own local rotation for the gravitational direction. If false, it will use the world's direction. This is used when you wish to have the gravity directed sideways. Set this value to True and then rotate the GravityBox onto its side.

Gravity sphere


Much like the GravityBox, the GravitySphere holds all the same principles but in a radius instead of a bounding box. The only other difference with the GravitySphere is that a false uniform Boolean will cause any object within the sphere to be attracted/repulsed from the center of the axis.

 

Hangman on a rope


In this recipe, we will look at how we can utilize a rope to hang a dead body from it.

Getting ready

  • Open Sandbox
  • Then open My_Level.cry

Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at $19.99/month. Cancel anytime

How to do it...


Begin by drawing out a rope:

  1. Open the RollupBar.
  2. From the Misc button, select Rope.
  3. With Grid Snap on and set to 1 meter, draw out a straight rope that has increments of one meter (by clicking once for every increment) up to four meters (double-click to finalize the rope).
  4. Align the rope so that from end to end it is along the Z axis (up and down) and a few meters off the ground:

    cryengine-3-fun-physics-img-2

  5. Next, we will need something solid to hang the rope from.
  6. Place down a solid with 1, 1, 1 meter.
  7. Align the rope underneath the solid cube while keeping both off the ground. Make sure when aligning the rope to get the end constraint to turn from red to green. This means it is attached to a physical surface:

    cryengine-3-fun-physics-img-3

  8. Lastly, we will need to hang a body from this rope. However, we will not hang him in the traditional manner, but rather by one of his feet.
  9. In the RollupBar, click on the Entities button.
  10. Under the Physics section, select DeadBody.
  11. Rotate this body up-side-down and align one of his feet to the bottom end of the rope.
  12. Select the rope to make sure the bottom constraint turns green to signal that it is attached.
  13. Verify that the Hangman on a rope recipe works by going into game mode and punching the dead body:

cryengine-3-fun-physics-img-4


How it works...


The rope is a complicated cylinder that can contain as many bending segments as defined and is allowed to stretch and compress depending on the values defined. Tension and breaking strength can also be defined. But since ropes have expensive physics properties involved, they should be used sparingly.