SetPhysicsMode

Sets the entity physics mode.

Syntax

Parameters

Remarks

If you don't want an entity to use any physics at all, set the mass to 0 with Entity::SetMass().

When an entity uses character physics, the physics will control the object's rotation, and calls to Entity::SetRotation() and similar functions will have no effect.

Example

#include "Leadwerks.h"

using namespace Leadwerks;
Entity* entity = NULL;
int main(int argc, const char *argv[])
{
Leadwerks::Window* window = Leadwerks::Window::Create();
Context* context = Context::Create(window);
World* world = World::Create();
Camera* camera = Camera::Create();
camera->SetRotation(35, 0, 0);
camera->Move(0, 0, -6);
Light* light = DirectionalLight::Create();
light->SetRotation(35, 35, 0);

//Create the ground
Model* ground = Model::Box(10, 1, 10);
ground->SetPosition(0, 0, -0.5);
ground->SetColor(0.0, 1.0, 0.0);

//Create a shape
Shape* shape = Shape::Box(0, 0, 0, 0, 0, 0, 10, 1, 10);
ground->SetShape(shape);
shape->Release();

//Create a model
entity = Model::Box();
entity->SetColor(0.0, 0.0, 1.0);
entity->SetPosition(0, 3, 0);
entity->SetMass(1);

//Create a shape
shape = Shape::Box();
entity->SetShape(shape);
shape->Release();

while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;

Leadwerks::Time::Update();
world->Update();
world->Render();

context->SetBlendMode(Blend::Alpha);
context->DrawText("Mass: " + String(entity->GetMass()), 2, 2);

context->Sync();
}
return 0;
}