Solution For Hide my Actor
I am Trying to find solution for hide camera when camera collide with actor so that i can prevent seeing through my actor but it only works when my actor is moving any solution please?
asked Jan 22 '19 at 07:12 PM in Using UE4
I think the reason your approach wasn't working has to do with the collision profiles of your character's mesh and that of your sphere collider. It might be tricky to find a combination that allows for an overlap to occur without negatively affecting the character's typical collision behavior.
So, instead of going about it that way, I found two solutions that worked using other techniques. Have a look:
The screenshot above shows the first way I solved the problem using a very inexpensive squared-distance comparison. Using this approach, you specify the closest distance the camera is allowed to be to the camera's orbit point (the end of the camera boom), and if the camera gets closer than that distance, the character is hidden. The drawback of this approach is that it might be impossible to find a value that works satisfactorily for all viewing directions. I noticed that a distance of 80 units worked well for hiding the character when the camera was approaching from the side, but it didn't work as well when the camera approached from the bottom. You could probably interpolate between a couple of values using the camera's rotation to improve this technique somewhat, but it would never be "perfect", though it might be "good enough" for most situations.
Here's my other approach:
This second approach is effectively the same as what you were trying to accomplish, but thankfully it works without having to worry about collision profiles. It takes advantage of the Get Closest Point on Collision node, which helpfully returns 0 if the provided point is within the collider. So if the return value is exactly equal to zero, the character's mesh is hidden. The downside of this approach is that it's not as beautifully inexpensive as the first approach, because it presumably relies on line traces, but this isn't a problem if you're not extremely concerned about optimizing your game. Besides, the upside is, it works from all directions, unlike Approach 1.
Hopefully one or both of those solutions helps you out and gets you closer to your goal. Let me know if I can help explain things any better!
answered Jan 23 '19 at 01:20 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here