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

Hi. I have a model of a maze which the player has to traverse through. I had problems getting the actual collisions to work but now the player doesn’t walk through the model. Although now when the player/camera hits the wall of the maze the camera glitches out and ``runs away’’ from the player (I can’t think of a better way to describe it). I used blend2bam to generate the collision solid around the model of the maze and I am using wolf’s character controller to control my character but I can’t understand why this would be happening. I have uploaded a link video clip of this happening as I feel it would be better to see it rather than me poorly explain what is happening

Link to google drive containing video clip and bam file of the maze model

I really do not know where to start on solving this problem so any help is appreciated.

I would guess that it’s something to do with either your collision setup or your collision code.

Hmm… Does your camera have collision-geometry of its own, separate from that of the character?

All the camera controls are taken care of using the character controller. I just had a scan through the code and from what I could see I don’t think there is any collision geometry around the camera, I could be wrong. I will try and add collision geometry to the camera to see if that works.

Er, no, I don’t recommend adding collision-geometry to the camera–I was more concerned that it was present, as it seemed like a potential source of such problems! ^^;

That said, alas, I’m not all that familiar with the character-controller in question, I’m afraid, so I’m not sure of what it does internally, and thus what might be causing the issue that you’re seeing. It is very odd! :/

From what I could tell from the code, there were no collision solids on the camera (unless I missed it) and after adding the collision solid around the camera I can see why you wouldn’t have recommended it as it caused a considerable camera shake. I have been trying to figure out what could be causing the camera to run off like that. I may have to contact wolf directly to see if they know what could be causing the issue.

1 Like

You should use this to see collisions:


It kinda looks like you intended to change the position of the character when some collision occurs but instead you are changing the position of the camera.
Maybe there is some collision solid on the character thats supposed to be on the camera.

There is an option in the character controller file that will show all of the collisions and this is what it looks like:

there is also a first-person camera mode, when I switch to this the camera does not ``bounce’’
off the walls but the player will sometimes get stuck inside the corridor of the maze. Like I said previously i am using Wolf’s character controller which handles the camera modes so I am not 100% if it is working correctly, I did speak to wolf previously and because I am using the fox model supplied with the controller everything should be working correctly which is why this problem is confusing me so much.

Yeah, it seems the two balls are probably for the camera. And the 3 lines are the character. So do the balls move with the camera? I guess they stay in place when the camera starts drifting right?

I know that one of the spheres is for the player collision which is what wolf told me.

that is what happens when the player is touching the wall I will add a link to another video of what happens when the camera runs off again to see if showing the colliders gives any more information:

video link this is to the updated video, showing the colliders. The only thing that I notice is that there is what seems to be a ray that follows the camera before it finds its position behind the player again.

As the camera is “running away”, there’s a brief glimpse of a huge collision-sphere. What is that?

I guess you will need to set Bitmask on each col. node to 0 to see which one is controlling the camera and debug it. I notice there is second vertical line when the camera drift starts. But no idea what is going on.

That is the bounding area of the environment as the big surrounding walls of the environment do not have collision solids, it just stops the player from running off the edge of the map

Ah, I see–and I presume that it’s an inverse-sphere (i.e. not a normal sphere), yes?

if that is the CollisionInvSphere, you are correct. Would it be wrong to use a regular CollisionSphere as a ``bounding box’’?

It would be a bad idea, I think, indeed: after all, a collision sphere is considered to be “solid” on the inside, and thus anything within it would always be colliding with it, I believe.

Conversely, a collision inverse-sphere is considered to be “solid” on the outside–that is, all space outside of the sphere is considered to be “solid”–and thus things fully inside of it aren’t in a state of colliding with it. (Although things outside always collide with it, I believe.)

1 Like

I just double-checked the character controller code then and the two spheres that are seen in the video are supposed to belong to the character and not the camera (I presume from this code)

Yeah, I thought they are for the camera because from the screenshot they seemed to be behind the character. The smaller ball is obviously for keeping the character out of walls etc.
I looked at the code and apparently there is a ray to control the camera.

You should probably poke in this function panda3d-character-controller/ at 5cdccc94db1586e4163676b8f971e5097b531d68 · fireclawthefox/panda3d-character-controller · GitHub
I would try to add print(camdist) at line 258 to see if that part is what keeps moving the camera.

It doesn’t seem to be that part as when the camera goes flying away it is still printing the same camera distance. I set the camera distance to be closer to the player so it happens less often, which is a little fix for now I suppose. The camera doesn’t seem to bounce off the walls if I use the first-person option so I might just have to use that if I cannot find a complete fix.

Well it shouldnt keep printing the same distance. It should increase everytime. If it keeps printing smaller distance than is the min. distance then that is the bug.

edit: I mean when its drifting.

Yes that’s what i was thinking that when the camera bounces of the wall that the distance from the player that is sprinted the the console should be increasing but it isn’t.