Issue adding collider at runtime

Hello, on this project, I have a button which creates a house and then adds a couple components to that house including a mesh collider. I can add the mesh collider from the .json model file in the editor, but when I do it at runtime, if I click the house it looks like it doesn’t have any collider… I don’t know what to do.


Project :

Ok I got it to work by adding my model file to the collision.model instead of asset, but now it seems like my collider is way bigger than the actual house… How to prevent this ?

I cannot see a problem with the collider

you talking about this?

Nah this one is disabled in the editor… I’m talking about the difference between when you click and unclick the one that is already there when you launch and one that you would create using the blue square at runtime… It seems like the collider of the ones created at runtime is way bigger than it should…

No i dont see a problem it all good on my end hmmm try send a screenshot of ur problem if its visible
EDIT: Nevermind i see what you mean… when you click even away from the building to rotate the camera it pulls the UI for the building right?

Exactly, but if you try with the one that was created before in the editor, even if you click 1 cm next to it it deselects it compared to the house created at runtime, you have to click really far to unselect it…

Yes what seems to be happening is when you move the building the collision moves the opposite direction causing a +/- diversity so now you have to look at the place that makes your building move, when you do that make the collider a positive instead of a negative.

Ooof i’m not sure I follow you right here to be honest :open_mouth:

1 Like

The collider is moving in its own direction instead of updating with the model. i notice its not the same way with all of them some of them they follow but go faster and further

Don’t you feel that the collider is just wider than it should be ?

Ohh ok I see what you mean, but how do you manager the position of the collision :open_mouth: Isn’t it actually supposed to be linked with the entity ?

Actually it makes no sense because even if I don’t move it, it feels way bigger than it should so it’s not the movement the problem

Yes something must have happened when you coded the Pos of the building and created the opposite for the collision? Have you tried looking at your code maybe seeing if you can update the collider as well as the entity?

I am not touching the collider’s position at all… :open_mouth:

Ok well when moving the entity it is not updating so if you are correct then show the code that allows you to move the buildings. You have to be able to uupdate the collider as you do the entity movement or the collider will just spread every where you move the entity

The collider is linked to the entity so it must follow it when I move it …

Moving the entity is almost like moving something with the mouse the scene has to be updated or the collider will just spread example:
The scene starts off with one image but when you move your mouse this happens:
See what im saying the same thing is happening to your colliders
like so the tracking should happen like so
Screenshot of what your code should output

I’m pretty sure it is not doing this because I was doing the same thing with a box collider earlier and it was working real fine… And if it would be what you say, after couple minutes of moving around, I wouldn’t be able to unclick the house anymore but i’m still able to so I really don’t think there is a spread of collider :open_mouth:

1 Like

I’m almost 100% sure it is the collider size the problem but idk how to change that to fit the entity because the model i’m applying to the collider is litterally the same as the entity one