Jump to content

how to avoid flickering for moving objects?


PoussinJoyeux
 Share

Recommended Posts

Hello,

 

I'm back to Leadwerks after a long while and starting to play again with it and C++.

 

I've done a very basic code which moves a door (why not rolleyes.gif ).

 

#include "App.h"

 

using namespace Leadwerks;

 

App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}

 

App::~App() { delete world; delete window; }

 

Entity* EntityDoor;

float pos_z;

 

bool App::Start()

{

window = Window::Create();

context = Context::Create(window);

world = World::Create();

 

EntityDoor = Prefab::Load("Prefabs/Doors/gatevertical_door.pfb");

pos_z = 0;

 

//Load a map

return Map::Load("Maps/start.map");

}

 

bool App::Loop()

{

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

 

Time::Update();

 

pos_z = pos_z + 0.005f;

EntityDoor->SetPosition(10 , 10, pos_z);

 

world->Update();

world->Render();

context->Sync();

 

return true;

}

 

I can see it moving as expected but when I'm close to it, there is lot of flickering and it is even hard to keep looking at this moving door.

 

What are the tricks to allow a smoothing move? unsure.png

 

I guess there must be way to synchronize it with some refreshing update or else...

 

Thanks for your help!

Link to comment
Share on other sites

Disable physics for it, using SetPosition() on physics enabled objects isn't really how you are suppose to do it. You should use forces.

 

EntityDoor->SetMass(0.0f);

 

Also note that the door prefab you are using has a connected script : SlidingDoor.lua

 

You would be better off just loading the model file (mdl) for the door in your example, not the physics enabled prefab which also has a script attached to it.

HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...