Dreikblack Posted December 31, 2023 Share Posted December 31, 2023 For example in ThirdPersonControls virtual void Start() { smoothcameradistance = followdistance; auto entity = GetEntity(); entity->SetPhysicsMode(PHYSICS_PLAYER); if (entity->GetMass() == 0.0f) entity->SetMass(78); entity->SetCollisionType(COLLISION_PLAYER); //here auto collider = CreateMeshCollider(entity->As<Model>()); if (collider) entity->SetCollider(collider); camera = CreateCamera(entity->GetWorld()); camera->SetPosition(0, eyeheight, 0); camera->SetRotation(0, 0, 0); camera->SetFov(70); currentcameraposition = camera->GetPosition(true); freelookrotation = entity->GetRotation(true); } Quote Link to comment Share on other sites More sharing options...
Josh Posted December 31, 2023 Share Posted December 31, 2023 Are you certain that entity->As<Model>() isn't returning NULL? Why are you setting a collider? The player physics mode will create several cylinder shapes to handle the collision. 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...
Dreikblack Posted January 1 Author Share Posted January 1 6 hours ago, Josh said: Are you certain that entity->As<Model>() isn't returning NULL? Yes, i did check in my own component, just simplified it here. 6 hours ago, Josh said: Why are you setting a collider? The player physics mode will create several cylinder shapes to handle the collision. It's just an example for model that start map has. I don't use ThirdPersonControls or player physics mode in my project. Just wanted to apply a collision in Start om my units component. Have no problem with doing that outside of component while taking entities from world. Quote Link to comment Share on other sites More sharing options...
Josh Posted January 16 Share Posted January 16 The problem has to do with instantiating an animated model. Still investigating... 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...
Josh Posted January 16 Share Posted January 16 This works fine: #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto world = CreateWorld(); auto model = LoadModel(world, "Models/Developer/Player/player.mdl"); auto inst = model->Instantiate(world); return 0; } 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 January 16 Solution Share Posted January 16 I see what was happening. The mesh collider routine creates an instance of the model and collapses it, then uses that mesh data to build the shape. But it was using the default parameters for instantiation, which includes running the start function for any attached components on the new model. So it was creating an infinite recursive loop. 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.