PoussinJoyeux Posted November 8, 2015 Share Posted November 8, 2015 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 ). #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? I guess there must be way to synchronize it with some refreshing update or else... Thanks for your help! Quote Link to comment Share on other sites More sharing options...
shadmar Posted November 8, 2015 Share Posted November 8, 2015 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. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
PoussinJoyeux Posted November 8, 2015 Author Share Posted November 8, 2015 Thanks Shadmar for your quick answer! So I followed your advice and used a model instead and it now moves smoothly in the sky. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.