Colliding with model makes camera ``run away'' from player

If you cant fix it yourself then you wont get far. Panda isnt made to be used without understanding. There are harder obstacles ahead.

Hmm… How complex are the interactions that you intend?

If you’re making something simple, then perhaps it’ll be easier and more reliable to make your own character-controller–something that you know the internals of, and are familiar with.

For example, if you only need wall-collisions, then you might get away with nothing more than one collision-sphere, and perhaps some handling for the camera–perhaps a ray for a very simple implementation.

Hi @kian5749 I just was able to check your model and reproduce the problem.

I noticed your model has quite a large scale applied to it (actually 229.131). This often results in inaccurate collision detection.

To fix this, go in blender and apply the scale at least on the collision solids by pressing Ctrl-A then select Scale. This will change the scale of your model to 1 while keeping it’s actual size. Export your model again and try if that already fixes the problem.

2 Likes

Ah, yes–I believe that, in general, scaling factors can cause problems for collision detection; it’s generally better, to my understanding, to have one’s collision geometry be un-scaled.

Ah, the classic Panda3d and scaling. We need to make some Panda3d commandments and the first one should be:

  • Thou shalt not scale objects with collision nodes.

If you do intend scaling, don’t reparent the collision np to the model np, reparent both of them to a common np. LIke:

mainNP = render.attachNewNode("mainNP")
modelNP.reparentTo(mainNP)
collisionNP.reparentTo(mainNP)

# And manipulate mainNP wherever needed. This way, everything below it will move.
1 Like

Thank you! So in the future, if I need to scale something within my scene, I should scale the size of the model in Bender and not use the setScale method to change the scale of my model?

If it’s about collision geometry, I’d recommend to model them at the correct scale from the beginning and not scale them in any way. That should always ensure correct collision calculations. If you have to scale it, you should do it in blender and apply the scale as I’ve described before.

1 Like

If in-game dynamic scaling is required, perhaps calling “flattenStrong” on the collision geometry might work (after removing or bypassing any model-nodes, if present).

I haven’t tried this myself, and don’t claim to know that it will work and won’t incur further problems, but it seems like something that might work.

Yes, but also, the reason why adding collision nodes to a scaled model is not correct is because the model is scaled, not the collision node. So it will just act as a collision node which was never scaled and will detect collision for an un-scaled version of the model. To overcome this, there are 2 ways:

  1. scale the model after attaching the collision node, so that the collision node gets scaled with the model
  2. Do the setup above and scale mainNP. This way, all NodePaths below mainNP (i.e. modelNP and collisionNP) will get scaled to what you specified.

@panda3dmastercoder thats what you should NOT do. :smile:

Maybe it is, but I am very bad at trying to explain things, so maybe there were some misreadings.