Stop

This function stops the entity from following or moving to a point.

Syntax

Example

#include "Leadwerks.h"

using namespace Leadwerks;

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,-8);
Light* light = DirectionalLight::Create();
light->SetRotation(35,35,0);

//Enable navmesh debugging
camera->SetDebugNavigationMode(true);

//Create the ground
Model* ground = Model::Box(10,1,10);
ground->SetPosition(0,-0.5,0);
ground->SetColor(0.0,0.25,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
//This is an obstacle the player will walk around
entity = Model::Box(1,1,3);
entity->SetColor(0.0,0.0,1.0);
entity->SetPosition(0,5,0);
entity->SetMass(1);

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

//Enable navigation obstacles
ground->SetNavigationMode(true);
entity->SetNavigationMode(true);

//Create a character
player = Pivot::Create();
Entity* visiblecapsule = Model::Cylinder(16,player);
visiblecapsule->SetScale(1,2,1);
visiblecapsule->SetPosition(0,1,0);
player->SetPosition(-4,0,0);
player->SetMass(1);
player->SetPhysicsMode(Entity::CharacterPhysics);

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

Vec3 targetpos = Vec3(4,0,0);

if (!pathset)
{
pathset = player->GoToPoint(targetpos,1.4,1);
}

//Stop the player when he gets close to the destination
if (player->GetPosition().DistanceToPoint(targetpos) > 2.0)
{
player->Stop();
}

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

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

context->Sync();
}
}