[quote=“carnalis”]If setup like the samples, the physics system should prevent things from falling through, and it applies forces from collisions (like bounce). RigidBody has attributes to set its restitution, friction, etc.
Maybe in your setup stage, you miss a SetCollisionLayer() for your terrain/surfaces/bodies, or do not add that in the editor?[/quote]
Hi
I doubt it. I’ll copied parts of the xml and code to here. When I open the .xml in the editor both says collision layer 1. Maybe I have to manually edit the xml and add the collision layer?
Vivienne
airbike2.xml
<node id="16777246">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="" />
<attribute name="Position" value="0 -0.207637 0" />
<attribute name="Rotation" value="1.37679e-07 -1.37679e-07 0.707107 0.707107" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<component type="StaticModel" id="16777270">
<attribute name="Model" value="Model;Models/airbrake.plane.mdl" />
<attribute name="Material" value="Material;Materials/airbrake.plane.xml" />
</component>
<component type="CollisionShape" id="16777271">
<attribute name="Shape Type" value="ConvexHull" />
<attribute name="Model" value="Model;Models/airbrake.plane.mdl" />
<attribute name="LOD Level" value="1" />
</component>
<component type="RigidBody" id="16777272">
<attribute name="Physics Rotation" value="1.37679e-07 -1.37679e-07 0.707107 0.707107" />
<attribute name="Physics Position" value="0 -0.207637 0" />
</component>
</node>
terrain.xml
<node id="16798325">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="Terrain" />
<attribute name="Position" value="0 0 0" />
<attribute name="Rotation" value="1 0 0 0" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<component type="Terrain" id="16777303">
<attribute name="Height Map" value="Image;Textures/heightmap2.png" />
<attribute name="Smooth Height Map" value="true" />
<attribute name="Is Occluder" value="true" />
<attribute name="Cast Shadows" value="true" />
</component>
<component type="RigidBody" id="16777304">
<attribute name="Collision Event Mode" value="Always" />
<attribute name="Use Gravity" value="false" />
</component>
<component type="CollisionShape" id="16777305">
<attribute name="Shape Type" value="Terrain" />
</component>
</node>
Code
[code]void ExistenceClient::CreateCharacter(void)
{
// get resources
ResourceCache* cache = GetSubsystem();
Renderer* renderer = GetSubsystem();
Graphics* graphics = GetSubsystem();
UI* ui = GetSubsystem();
FileSystem * filesystem = GetSubsystem();
//String characternode = String("Character");
LoadCharacterMesh("Character",1,1);
Node* objectNode = scene_->GetChild("Character");
// Create rigidbody, and set non-zero mass so that the body becomes dynamic
RigidBody* body = objectNode->CreateComponent<RigidBody>();
body->SetCollisionLayer(1);
body->SetMass(.2f);
// Set zero angular factor so that physics doesn't turn the character on its own.
// Instead we will control the character yaw manually
body->SetAngularFactor(Vector3::ZERO);
// Set the rigidbody to signal collision also when in rest, so that we get ground collisions properly
body->SetCollisionEventMode(COLLISION_ALWAYS);
// Set a capsule shape for collision
CollisionShape* shape = objectNode->CreateComponent<CollisionShape>();
//shape->SetConvexHull(cache->GetResource<Model>("Resources/Models/standardfemale:Body.mdl"));
shape->SetBox(Vector3::ZERO);
shape->SetLodLevel(1);
character_ = objectNode->CreateComponent<Character>();
// Create a scene node for the camera, which we will move around
// The camera will use default settings (1000 far clip distance, 45 degrees FOV, set aspect ratio automatically)
Node * cameraNode_ = objectNode ->CreateChild("CameraFirstPerson");
// Set an initial position for the camera scene node above the plane
cameraNode_->SetPosition(Vector3(0.0f,0.1f,-0.185821f));
cameraNode_->SetRotation(Quaternion(0.0,-180.0,0.0));
Camera* cameraObject = cameraNode_->CreateComponent<Camera>();
cameraObject->SetOrthographic(0);
cameraObject->SetZoom(1);
ExistenceGameState.SetCameraMode(CAMERAMODE_FIRSTPERSON);
// Set up a viewport to the Renderer subsystem so that the 3D scene can be seen. We need to define the scene and the camera
// at minimum. Additionally we could configure the viewport screen size and the rendering path (eg. forward / deferred) to
// use, but now we just use full screen and default render path configured SetOrthographic ( in the engine command line options
//viewport -> SetCamera(cameraObject);
SharedPtr<Viewport> viewport(new Viewport(context_, scene_, cameraObject));
renderer->SetViewport(0, viewport);
return;
}[/code]