SetFriction
Sets an entity's static and kinetic friction.
Syntax
- void SetFriction(float staticfriction, float kineticfriction)
Parameters
- collisiontype: staticfriction: the resistance that must be overcome when an object at rest begins moving.
- recursive: kineticfriction: the resistance that must be continually overcome as an object slides along a surface.
Example
#include "Leadwerks.h"
using namespace Leadwerks;
Entity* entity1 = NULL;
Entity* entity2 = 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(15, 0, 0);
camera->Move(0, 0, -8);
Light* light = DirectionalLight::Create();
light->SetRotation(35, 35, 0);
//Create the ground
Model* ground = Model::Box(10, 0.1, 10);
ground->SetColor(0.0, 1.0, 0.0);
//Create a shape
Shape* shape = Shape::Box(0, 0, 0, 0, 0, 0, 10, 0.1, 10);
ground->SetShape(shape);
shape->Release();
//Create a model
entity1 = Model::Box();
entity1->SetColor(0.0, 0.0, 1.0);
entity1->SetPosition(-2, 1, 2);
entity1->SetMass(1);
entity1->SetFriction(0, 0);
entity1->AddForce(0, 0, -200);
//Create a shape
shape = Shape::Box();
entity1->SetShape(shape);
shape->Release();
//Create a second model
entity2 = entity1->Instance();
entity2->SetPosition(2, 1, 2);
entity2->SetFriction(1, 1);
entity2->AddForce(0, 0, -200);
while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
Leadwerks::Time::Update();
world->Update();
world->Render();
context->Sync();
}
return 0;
}