Havok physics is the property which allows game objects to move around. Although there are some objects in the actor class browser that already have Havok Physics preconfigured, (for example crates and barrels, under WorldObj->SetDressing) sometimes you might just want to add physics to any arbitary object, such as a statue or sofa, to make it possible to push it around or knock it over.
How to add Havok to an objectEdit
Add the meshEdit
If you haven't already, open the static mesh browser to place a static object in your map. As an example object, we'll use a hammerite cross.
Browse to STATUE and select HAMhammerstatue. If you have trouble seeing an object in the preview window of the browser, try right clicking and dragging SouthEast with the mouse. Once you've selected your static mesh, right click somewhere on your map, and choose Add SM: 'meshname' here
Add dynamic shadowsEdit
Because your object is going to be able to move, you probably should enable dynamic shadow casting for the object, or it will look rather silly. So right click on the object and choose the top option StaticMeshActor Properties.
Expand the bottom properties, expand render, and if you don't see Shadow_Casting_True, right click Render, Add property, choose CastShadows in the right list, Add property, then make sure its set to Shadow_Casting_True.
Now we have to tell the engine and renderer the object is movable, and tell it to use havok physics to control the movement. Back in the bottom most properties for the StaticMeshActor, expand Actor, we need bNotMoveablePhysics and bNotMoveableRender. If they are not there, right click Actor, add property, select them both in the right window (control allows multiple selection) and add property.
Now make sure they're both set to False.
From now on I'll be more terse on how to add properties, and just list them. Under Movement, you'll need to add Physics, and select the default PHYS_Havok.
Now we can do some basic customization of the physics properties of the object. Right click on Properties, select Physics in the left column, and Multiselect Friction, InitialHavokState, MassPounds, and StartActive, and add them. Also go back in and add Physics Sound (left column) / ObjWeight (right column)
Back in the properties window, set the Friction to 0.5, make sure InitialHavokState is set to Havok_HavokControlled, set MassPounds to 50, and set StartActive to False.
Under PhysicsSound -> ObjWeight, set it to Weight_Heavy.
Now make sure that you position the cross level with the ground, and run your map. You should find you can walk into the cross and knock it over fairly easily.
Explanation of settingsEdit
Setting bNotMoveablePhysics seems to be a flag to the engine that the object is moveable, and as well as allowing objects to move, affects the generation of the NavMesh. (The grid that helps AI's navigate the map)
With this option set to True (default) the Navmesh will build around the object, causing AI's to try and walk around it, while setting it to False causes the NavMesh generation to ignore the object. (AI's don't "see" it, they try to walk through it, and in the process push it around). In any case, it must be False for an object to be able to move.
Setting bNotMoveableRender seems to be a flag that tells the renderer whether it can precalculate a model or whether it has to dynamically calculate it.
If you leave this setting on true, you can still push the object *physically* but the visual representation stays in the same place. So you end up with an invisible object being pushed around and a visible ghost that you can walk through....(amusing, but not terribly useful)
Friction controls the amount of drag between object surfaces and other objects. 0.5 is a good starting point, but if you want an object to be able to slide easily without falling over (such as a sofa) you might want to set it as low as 0.1, otherwise it will tend to stick.
On the other hand, a tall skinny object you want to be able to knock over rather than slide, needs the friction set higher, 0.5 or more so that there is enough drag at the base to allow it to tip over. A very heavy object with high friction cannot be pushed by Garrett at all.
MassPounds is the "virtual weight" setting of the object, and it affects how easy it is to push or knock over, relative to the strength of Garrett. 50 is a light object easy to push over, 200 - 500 is a heavy object but still pushable, while 2000 is too heavy to push depending on the friction and surface contact area. Things below 200 can also be knocked over with arrows.
The weight also seems to affect the damage that happens to AI's if something falls on them. A weight of 200 doesn't hurt them much, but a weight of 2000 will kill an AI if it falls on one.
StartActive controls whether the physics simulation for the object starts immediately, or only after it is touched by another moving object. (Garrett, AI's, other objects like thrown barrels etc)
The main reason I can see for this is conserving CPU resources. Without being able to set StartActive to False, EVERY SINGLE physics object in your entire map, including junk items like cups etc, would be having a continuous physics simulation calculated for them, even if the player never touches them.
So normally any object that starts the game in a "stable" state, for example a barrel sitting flat on the ground, should have StartActive set to False to conserve resources.
There can be some strange side effects to this if you don't position your objects very carefully though - if it is slightly off the ground, the first time you or another object touches it, it will fall to the ground. Or if it is an object that can rock, such as a hay cart, and it is placed at a non-stable resting angle, it may suddenly rock back and forth when it "comes alive" when touched. An object placed in midair will hover there until touched by something, then fall to the ground.
If you set StartActive to True, then the objects physics simulation will begin immediately, for example a barrel placed in mid air will immediately fall when the game starts.
PhysicsSound -> ObjWeight affects the sounds made when an object drags along the ground, or falls over.
Weight_Light makes sounds that sound like a goblet, Weight_Medium makes sounds like a barrel, and Weight_Heavy makes sounds like a stone statue.
Some objects make no sound, even when ObjWeight is set, probably because meshes used by these objects don't have materials properly assigned to them. To make such an object audible, add property Material -> MaterialOverride and choose one of predefined materials. This property does NOT determine the kind of sound object makes when it hits something, so if you set MaterialOverride to stone and ObjWeight to Weight_Medium, it will still sound like a barrel.
User:Mandrake: To give some examples of what can be done I've uploaded the map I did my testing on [Here]. (It is based on the test map made by doctormidnight - Thanks!)
All the objects in the map are moveable physics objects, with no significant slowdown in framerate that I could notice. Even the lamp posts can be knocked over.
At the top of some steps is a barrel that is perched deliberately to fall, but to allow it to actually fall when the game starts it is set to StartActive True.
On the other hand, to the left of the starting position is a tall pillar leaning over, but it is set to StartActive False. It will stay there until something (even an arrow) touches it, then fall over. Try shooting a noise maker arrow near the base of the leaning pillar so some Guards knock it over :cheeky:
Bumping the flame dish holding statue in the distance (either by arrow or walking into it) causes the dish to drop down etc...
- TTLG Forums Discussion
- Physicalizing Objects
- Mission Design: World Objects
- Mission Design Tutorials
- T3ed Tutorials