How to stop camera from showing inside the character when not blocked by them

I wanted to stop the camera from being blocked only by characters but still be blocked by environment actors, and I did managed to achieve that (inside the character I set ignore camera collision), but now because it isn’t blocked by characters anymore, it can go through them and you get this:

I still want to be able to see the character up close like this (the camera is from the right side character):

But as soon as the camera gets inside them to not show them anymore somehow. How can you achieve this?

I tried to attach to the Spring Arm Component a Box Collision set to OverlapOnlyPawn and do this:

And well, technically it does what I expected and the character is hidden when it touches it, but the character is also hidden on the other side client/server, so this isn’t a solution. :laughing:

In that video he goes over how to stop the camera from going though the environment which it isn’t a problem for me. As I said I made the camera to be blocked by everything except the characters, but now the camera can go inside them and show the eyes, the mouth… I want to somehow hide the character when the camera is inside them.

You need to have it block the capsule component.

Create a new collision object (project settings → engine → collision). Name it pawn capsule and apply it to your capsule component.

I don’t want to block the camera with the characters. And I did that already. The problem that I have is that you can see inside the character, and I want to stop only that and hide the character, but not block the camera.

If the camera goes inside the character you will see what you see. You have to prevent the camera from entering the skeletal mesh.

If you block the camera then you get into this situation which is ugly and annoying for the player.

That is why I don’t want the camera to be blocked by the character, and have a way to hide the character when it is inside or too close.

Another approach

This isn’t really a feasible approach. Not only that you need to buy a plugin but you also need to change the materials of the characters, which each of them have more then one material (head, chest, legs, accessories…).

The first style of the plugin you can’t use because it only makes the material transparent, but not invisible, so the eye for example will still appear but transparent.
The second style isn’t supported for SkeletalMesh.
And for the third and forth style you need to change the materials.

There are only two approaches and both of them are here.

  1. Camera collides with obstacles
  2. Camera shows through obstacles
    Each of them has pros and cons, you need to decide what fits better your game.

Don’t get me wrong, maybe the 2nd option you posted would work, but that isn’t something someone without a revenue from other games/project can use. Yeah a big company can buy plugins, but for someone like me that approach isn’t feasible. I can’t simply spend some money on each problem that I may have to simply buy a plugin to fix it or make things go faster, or whatever else.

And like I said, this approach is the one I’m after, so that the camera doesn’t get blocked, but I need to find a way so that characters near the camera in a range aren’t showed. You don’t just have to stop at “well camera goes inside the object and that is all, it will show the inside”. There are ways to go about it.

Ok, here is the simplest way to fix the issue with the first approach, you can try to hide any character that collides with the camera.

In a single player situation this would have been easy, as you wouldn’t have cared if that actor simply disappears as it would be out of the players view, but in MP scenario you are making someone else character invisible, which will show for everyone, and not just you.

Try this
1677587933121
An MP game has a ton of complexity even in simple stuff, if you’re a solo developer I’d recommend you switch to SP game, it will save a ton of time

I’m already quite deep into development, and I have tons of ideas for it. If by the time I’ll publish the game I won’t find a solution to this, then I’ll leave it like that, and maybe I’ll add a patch that fix it. I won’t let something as simple as this to stop me, and any future problem I’ll keep try to find a way.

Unfortunately this is replicated, I tried it already as I seen somewhere that the root shouldn’t be replicated, but it is (maybe it was added in 5.0, as the post I read was pre 5.0 release, or maybe they confused it with normal actors, and not characters, but I didn’t need it for those types). It would have been nice to have the option of choosing if we want stuff to be replicated or not. Changing the location of an actor is replicated, but changing the scale isn’t, like that isn’t important, and you have to make your own way to replicate that (at least that is really easy to replicate, the scale I mean).

Camera collision begin overlap → skeletal mesh → Owner no see (TRUE)
Camera collision end overlap → skeletal mesh → Owner no see (FALSE)

Here is a solution:

  1. Inside the character add a Box Collision that is attached to the camera (I named it “CollideMesh”) so that it moves with it:

image

  1. Set the Collision Presets of the box to OverlapOnlyPawn.
  2. Inside a Graph create the event On Component Begin Overlap, and in it first check if the owning (self) character of the box that triggers the overlap is locally controlled. You need this check because if the overlap is triggered on the server side, then it will run only on the server, but if the overlap is triggered from a client, then it will run on that client as well as on the server, but you only want the character to disappear locally. After the check, cast the Other Actor to Character (because the box is set to collide with Pawns only, they will have the top parent type Character), then get the mesh from the character and use Set Hidden In Game true.
  3. Now inside the Graph do the same thing for On Component End Overlap, but this time at the end set it to false.

Set the scale/location (Transform) of the Box Collision to which value you want/need to change at which distance from the camera it will hide/show the character. I recommend that the scale from behind the camera to be bigger then the one in front, as the character will be behind the view of the player so he won’t see any difference, but it will make sure that you don’t get into the problem of the scale being too small and not hiding the character properly.

This doesn’t work while character is standing in place, or in other words if you are moving your camera around while standing still, because the collision attached to the spring arm isn’t considered as “moving” and won’t call overlap until character moves.

Correct alternative to this problem is to calculate distance between camera component and mesh component on tick, and when this distance is lower than your threshold, hide the mesh.