Forum rules - please read before posting.

Third person camera, walls collision and the collision offset

edited December 2018 in Technical Q&A

Hi!

I have a slight problem with the third person camera.
The camera in the scene is set behind the player, with horizontal offset 0.8, vertical 1.09 and distance from the target 2.
Like this:

As you can see in the preview it does not exactly work when the player stands close to the wall and is more or less parallel to it. It works much better when the horizontal offset is 0 though.

So here comes Collision offset to the rescue. As far as I understand, it's supposed to make the camera believe that the wall is a bit thicker, and to stay farther away from it.

But it doesn't work when the player stays parallel to a wall. Then I try to increase the offset, here is what happens:

The camera reacts, but it does not move away from the wall. It moves kind of forward. And the result looks bad, because the camera is still in the building. If I increase the value further, the camera keeps moving forward and it actually never leaves the building. So in this situation the offset does not help at all.

Unfortunately, such situations happen in the game pretty often. Every time a player hits a wall and then rotates to move away from it, there is a moment when the camera sinks into the wall and for a split second there is a mess on the screen.

Shouldn't the "collision offset" move the camera perpendicular to the wall, though? Or at least in the general direction of "away from the wall"? I can't see how I can fix that problem, other than not using the horizontal offset at all. It helps, but not good enough either. The collision offset does not make the camera move away from the wall, even then horizontal offset is set to 0.

So, how can I fix that?

Comments

  • Collision corrections occur by moving the camera further towards it's "centre-point", not in the direction of the collider's normal or anything like that.

    As you're reliant on the "Default" layer for collision detection, it may be that it's also being influenced by the Player. Is the Player itself on the Default layer with a collider / rigidbody or character controller?

    I shall try to recreate the issue - thanks for the Inspector screenshots and details.

    However, AC's built-in third-person camera is, admittedly, fairly basic. If you're heavily reliance on a third-person camera for your game, it may be worth looking for a more dedicated solution or asset to handle just that. It's entirely possible to plug in third-party cameras into your game - see the Manual's "Custom cameras" chapter if this is something you end up considering.

  • I tested with the player both on "Default" layer and on a different one. The results are the same. Changing the offset makes the camera move away, but in a poorly chosen direction.

    Well, custom camera is always an option. But I still hope it is something relatively easy to fix. I don't need the best solution, I just need good enough.

  • edited December 2018

    A very quick fix would be to have an additional "CameraCollision" collider/layer that is larger than the building but used specifically to keep the camera from getting too close.

    Having the camera simply move away from the wall in the direction of its normal isn't actually ideal, IMO - since e.g. rounded collisions could cause erratic behaviour. However, there are some improvements I can make to the algorithm - look out for these in v1.66.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.
Do NOT follow this link or you will be banned from the site!