I am playing around with unreal engine 5.4 and I have an issue with a task related to fixed cameras and trigger boxes.
I want to make a level where, when my character enters a collision box the camera changes. So far so Good, I followed a YouTube video and I have a camerachangeBP where I check the begin overlap with the 3rd person character and I change the camera via the “set view target with blend”. It works as intended with one issue.
When I have 2 boxes next to each other and I move from one to the next, if I turn around the moment the trigger happens (i.e. the moment I begin overlap) then the camera changes to the new box but my character is located in the old one.
You need to “remember” the zone you want to move to when the “begin overlap” is triggered in that zone, and change the camera when you “end overlap” the zone you are in.
I figured the solution for the change, and maybe people can use it or improve it (for which I am most happy to see suggestions etc)
Because I intent to use a few cameras in the level, to make sure that ticks will not start running and take computational power I added an “Event BeginPlay” to “Set Actor Tick Enabled” and i un-ticked the “Enabled”. This means that no tick event will start.
Then “On Component Begin Overlap” I added a “Set Actor Tick Enabled” with “Enabled” ticked. This means that the Tick event will start the moment my character collides with the collision box.
Now bellow is the rest of the logic (I added comments to explain things a bit):
It starts with checking to find if the character overlaps with the collision box (box is the name of the collision box). Then it gets the bounds of the box and the Character capsule (this is important because the character’s actor bounds X & Y values are changing a lot when you turn the character around while the capsule is a cylinder so it doesn’t). Then it checks to see if the character capsule is in the box (if someone has a better idea on how to do it, please do tell!).
If the character capsule is in the collision box then it changes the camera to the “ActiveCamera”. ActiceCamera is a camera variable I added to the blueprint which has the value of the camera that the collision blueprint box has assigned (like, you add a camera actor and then you assigned it as “ActiveCamera” in the collision box blueprint settings). Finally, after the camera changes, the tick stops.
I hope that will help all the people who have the same issue as I had and I am eager to see any improvements!