Jump to content

Collider Not Removed From Object


Go to solution Solved by Josh,

Recommended Posts

Posted

Not sure if this is a bug or not a good way to use the physics engine ;)

The box will still collide with the floor if you store it's collider elsewhere and set the boxes collider to nullptr.  Are colliders unique to the object they are applied too?

#include "UltraEngine.h"

using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    auto displays = GetDisplays();
    auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    auto framebuffer = CreateFramebuffer(window);
    auto world = CreateWorld();
    world->SetGravity(0.0f, -2.0f, 0.0f);

    auto camera = CreateCamera(world);
    camera->SetClearColor(0.125);
    camera->SetPosition(0, 0, -8);
    camera->SetDebugPhysicsMode(true);

    auto light = CreateDirectionalLight(world);
    light->SetRotation(35, 35, 0);

    auto box = CreateBox(world);
    box->SetMass(1.0f);
    box->SetColor(0, 1, 0);

    auto store = box->GetCollider();
    box->SetCollider(nullptr);//Will still collide...

    auto floor = CreateBox(world, 10, .1, 10);
    floor->SetPosition(0, -2, 0);

    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

Posted

Thankyou the example now works.  However there is a new issue - it appears if you set a collider to nullptr when the mass is zero the program will crash.  Comment out this line and it will crash.

   // box->SetMass(1.0f);

 

  • Thanks 1
Posted

Yeah, it's fixed, I just have not updated the lib. I'll do it within a couple hours from now.

  • Thanks 1

My job is to make tools you love, with the features you want, and performance you can't live without.

  • Josh locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...