SpiderPig Posted February 11, 2023 Share Posted February 11, 2023 The cube randomly bounces about but the collide member is only set to true for the first collision. After that it fails to work. #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 1440, 900, displays[0]); auto framebuffer = CreateFramebuffer(window); auto world = CreateWorld(); auto camera = CreateCamera(world); camera->Move(0, 2, -3); camera->SetClearColor(1, 0, 0); auto light = CreateDirectionalLight(world); light->SetRotation(35, 35, 35); auto floor = CreateBox(world, 100.0f, 0.5f, 100.0f); auto default_font = LoadFont("Fonts\\arial.ttf"); auto ui = CreateInterface(world, default_font, framebuffer->size); ui->SetRenderLayers(2); ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f); auto ui_camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); ui_camera->SetPosition((float)framebuffer->size.x * 0.5f, (float)framebuffer->size.y * 0.5f, 0); ui_camera->SetRenderLayers(2); ui_camera->SetClearMode(CLEAR_DEPTH); auto label = CreateLabel("", 10, 10, 500, 200, ui->root); auto box = CreateBox(world); box->SetMass(1.0f); auto actor = CreateActor(box); auto c = actor->AddComponent<CollisionCallback>(); box->SetPosition(0.0f, 5.0f, 0.0f); auto last_time = Millisecs(); while (window->KeyHit(KEY_ESCAPE) == false && window->Closed() == false) { auto time = Millisecs(); while (PeekEvent()) { ui->ProcessEvent(WaitEvent()); } WString text = "Position : " + String(c->collided ? "True" : "False"); label->SetText(text); if (time > last_time + 2500) { c->collided = false; box->AddForce(0.0f, 300.0f, 0.0f); last_time = time; } world->Update(); world->Render(framebuffer); } return 0; } Component: #pragma once #include "UltraEngine.h" #include "../ComponentSystem.h" class CollisionCallback : public Component { private: public: bool collided = false, is_updating = false; int collision_count = 0; virtual void Update() { is_updating = true; } virtual void Collide(shared_ptr<Actor> collidedactor, const Vec3& position, const Vec3& normal, const dFloat speed) { collided = true; collision_count++; } }; Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted February 13, 2023 Author Share Posted February 13, 2023 I checked it here as well. It's the actors collision method that is not being called. Josh are you able to take a look at this soon? 🙃 #ifdef DOUBLE_FLOAT void Actor::Collision(std::shared_ptr<Entity> collidedentity, const dVec3& position, const dVec3& normal, const dFloat speed, std::shared_ptr<Material> collidedmaterial) #else void Actor::Collision(std::shared_ptr<Entity> collidedentity, const Vec3& position, const Vec3& normal, const dFloat speed, std::shared_ptr<Material> collidedmaterial) #endif { ActorBase::Start(); auto actorbase = collidedentity->actor.lock(); std::shared_ptr<Actor> actor; if (actorbase) actor = actorbase->As<Actor>(); if (actor == NULL) actor = CreateActor(collidedentity); if (this->m_cameracontrols) this->m_cameracontrols->Collide(actor,position,normal,speed); if (this->m_collisioncallback) this->m_collisioncallback->Collide(actor,position,normal,speed); if (this->m_mover) this->m_mover->Collide(actor,position,normal,speed); } Quote Link to comment Share on other sites More sharing options...
Josh Posted February 13, 2023 Share Posted February 13, 2023 There will be an update for 1.0.2 later this week with fixes and some new features for image processing. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Solution Josh Posted February 17, 2023 Solution Share Posted February 17, 2023 Update will be available soon. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. 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.