Download

Is this custom camera possible?

Hey Everyone,
Been working with UE4 for a few days and it’s great! I started working with this type of Camera in UDK and never fully got it due to my limited knowledge of unrealscript. Now that Blueprint is here I thought I’d at least bring it up to perhaps see if any blueprint pros could shine some light on this idea :slight_smile:

I made a real rough mock up of what I would like it to do. Pretty much lock onto the character but if the viewing frustum would show pass the “room” you were in or show another area it would stop the camera. I wanted to do a side-scrolling type game but would like to avoid seeing into area’s where you shouldn’t until the play passes through the door.

In the video I had setup my idea (if it worked) of having camera blocking volumes that would block it from moving any further but I’m pretty sure that’s not possible in this exact way :slight_smile:

Thanks for any ideas to this!

This is something that would be fun to figure out (if I had the time). I’m sure something like this can be done in blueprints. Setting the camera to that position is the easy part, doing so in the components section of the character blueprint. The tough part is smoothing the camera movement in relation to the character’s movement. Just setting the camera in the blueprint will move exactly with the player, however.

I almost think instead of a camera blocking volume, there could be a simple trigger volume hit by the player as he approaches the door that sets the camera to a stationary position, then a trigger on the door functionality that moves the camera over.

Trigger volumes in the hallways could restrict the camera’s z axis.

Maybe the jump function could bypass the camera attachment to limit the camera from being too jumpy.

I’m trying to think of a way to give the camera a “soft” attach to the player.

Well this is me thinking out loud, hope it helps at all, or maybe someone else can jump in with some ideas.

Certainly, thanks for the input! I’ll play around with those ideas for sure and see if I can get anywhere. I’m still pretty early on in learning blueprints but I think it’s more possible now than before in UDK.

UD4 SideScroller template - Is it ?

Yes thats what it looks like, Thats a side scroller camera.

I do some images. Take a look at https://forums.unrealengine.com/album.php?albumid=6

Ok so my take on this is you should have the camera as a separate BP class with it’s own collision volume. This will make it easy to pick up the collisions with your trigger volumes.
Then you can use a Lerp(Vector) to set the cameras position based on the cameras current position and the player.
If the camera collides with a trigger volume maybe you can have it follow a path. This would be useful in the tight corridors where there’s no room for vertical movement. Just dont ask me how to do this :stuck_out_tongue:
At the doors you can have another triggervolume that checks if the door is open. If not, clamp the cameras X position to a set value for that door. If it is open, recenter the camera on the player.

Give it a go :wink:

Thanks for the replies! Yes, I’ve looked into the template in depth (still doing so) but I don’t want the exact generic LOCK on the character, what I would love to have is a bit more dynamic if possible. I’m trying to avoid the player from seeing too much of other areas or “rooms” until something happens or the player passes through a doorway for example.

I’ll try to explain a little more in depth (along with the video) of what my goal is. The area’s I’m working on are generally all going to be a certain minimum set size. lets juts say for example 100x100 is a square room and the camera fits within that room and the edges of the camera frustum are aligned with the room so the player can move all around this room and it isn’t locked on the player, so the player can move to the edges and next to a door but you couldn’t see the next area.

Say the player enters the doorway into a bigger 600x100 room (long hallway) the camera will be locked in the Z and Y axis, only moving in X (following the player) but staying within boundaries of the room. say there is a bigger 600x600 size in the next area… Same properties of the camera staying locked to start but once the player starts moving around and jump on some platforms for example then at THAT point the camera will be locked onto the player fully.

I hope it makes some sense. and I hope it’s some what possible :slight_smile: I’ve had a million ideas but not sure if any are possible and how to go about doing it. say perhaps I had a 100x100 triggers inside of my 600x600 room that once the player/camera was inside of it it would set different parameters

I apologize as this is probably the worst mock up I have done but hopefully it may help visually with what I’m thinking. I had something KIND of like this working… the probably I had though is it worked with 1st person/3rd person cameras BUT being as the side-scroller camera was locked onto the player it couldn’t changed the position. I’m still really early into testing this method but perhaps there is another to set this camera up… say instead of it being locked onto the Player it could be parented to perhaps a point or bone of the character in the blueprint. and that point is then parented to the player. Just thinking of different ways here to pretty much have both ways work :slight_smile:

I wonder can you put more the one collision box around the player? If you can you could have a collision box that is the same size as your camera view and when that collision box hits a bordering wall or floor it could stop your camera where you wanted. When comes to the doors you could put a collision box in that door and when you exits that collision box restart your camera.

I would love to have a collision for the camera, either having a camera setup in the level or a blueprint for it but couldn’t figure that out quite yet :slight_smile: I totally forgot about this but a PERFECT example of what I’m going for is a Shadow Complex type game.

Around 5:49 for the key elements

The camera is at a fixed stop at certain areas, such as next to doors, small corridor areas, etc. but also then is locked to the player, but it’s very dynamic it can come in really close or be far away which would be great. I’ve been messing with my Trigger idea, and have it working somewhat but I don’t think it will be exactly what I’m looking for. Right now each trigger has a camera and once the player is in the trigger volume it set’s the view with linear blend to that camera. but main issue with this is having trigger’s to close to each other still screw up the blend from active side-scrolling camera to the fixed camera so it’s a little jerky at times…

I think the MAIN thing here is focusing more on shadow complex and how they went about it exactly :slight_smile: And also having the map system on the top-right is something I was looking at but that’s going to be way in the future I think of my testing, maybe not even fully possible atm with the HUD.

Thanks everyone once again for the input!

Put the camera follow the player and make a trigger that offset the position of the camera over the player with this exposes var:

Xoffset float
Yoffset float
Offset Z position float
ForcePosition bool
ForceOnlyX bool
forceXoffset bool

i use this in my work.

>>>the issue is that entering these volumes from the outside makes the camera jumps

in this situation I use simple event, which fires timeline with alpha track for interpolation between old and new locations.
so it lerps like on your gif, but slower )

what about put invisible wall in front, constantly trace from camera center to the wall, if wall doesn’t hit, camera not moving? also you can make few type of “walls” and have few line trace in addition for your center. You would need to split the wall into parts and cover all level with them, but isn’t that’s why we have level designers? :smiley:

edit: or moving only if trace hit the wall, so you can control it precisely, again with few types of walls, to lock Z as an example.

no issues bro :smiley:

here

im not gonna polish this, but idea is:

you put invisible wall into level, there are one base “wall” and 3 addition each has number, the number means how many of “lockers or limiters” this wall represent, for easy level building.

Line trace from camera position X 1500 Z to camera x -600 Z, gameplay buffer and return all “Walls”

get all limiters and lockers from walls

build new vector 3d position for camera based on limiters and lockers

limiter is enum + vector3 struct, enum decide which function to call and vector 3d is the parameter for the function.

locker is enum + vector 3d(ignored, should be just enum, but im to lazy to implement, require refactor on wall), which applies after limiters (should be in the same time but im to lazy to optimize limiters) and basically undo limits if there are some.

after apply limiter and lockers we endup with Follow Location and thismove camera into this location little bit

next tick - all process from the start.

herethe list, only half of them implemented, which one you can check in BPAC_Fancy_Camera

idea of some of those:

Not Higher - Follow Location cannot be larger than current camera location
Not Lower - reverse ^
Not to the Left than - Follow Location cannot be more into left than current location
=/=/=/=/=

Lock High - Follow Location Z cannot change from current Camera Z
Lock LeftRight - Camera X cannot change from current Camera X
Lock CloserFurther - Camera Y cannot change from current Camera Y

you can add something like set X/Y/Z for addition to lockers which would use v3 parameter instead of current camera location for Follow Location.

mouse zoom implemented in a wrong way, just for testing.

not much, i like your a lot more than mine, especially camera jump, but mine is good(i dont know how is your) for pure level prototyping, only in editor without much typing.

First of all, you need to understand what exactly you want for this camera system.

1) As developer I want to define rooms, where camera movement will be limited by room edges.

Here you can see that camera really blocked on bottom and left side of first room, and not shows things behind it.
So, we may say that edges of this room is “closed” for camera movement.

2) As developer I want to define how camera moves between rooms.
Transition can be smooth - when camera position interpolates between rooms.

notice that bottom edge of this room is closed.

And transition can be cut - when camera “teleported” between rooms (this situaton is for closed edges also).

In situation when for 2 rooms edges are “opened”, between them camera simply moves with character, without any additional behavior.

3) As developer I want to change camera offset (zoom) in every room.
Yep, I really want it. Because in big rooms camera should be far from character, and in small rooms camera should be near.
AND (!) if room small, and all it’s edges are closed, I should calculate camera offset for this room, so camera view (frustrum) is fit to room correctly. :slight_smile:

Here is one additinal situation:

Notice that when character near the door, camera offset is near, but when he moved forward, camera offset becomes bigger.
This is when we have “room in room”. So, it’s just smaller room (with smaller camera offset) placed in bigger room (with bigger camera offset), and this smaller room have higher priority for camera calculations!

How this should work?
I use special “Camera Volumes”, which specifies my game rooms and additional parameters for camera. It’s actor with box and camera (for preview offset) components, edge indicators and additional things.

I detect when character overlaps new camera volume, add this volume to array of volumes overlapped by character, sort this array to get volume with higher priority and finally pass parameters of this volume to camera manager.

So my system works by events. Ofcourse you can calculate it every tick, using “GetOverlappingActors”, filter it by camera volume class and so on. But you should ask yourself is it really necessary. Because overlapping new camera volume is rare situation even in terms of 1 second, not tick.

How to limit camera movement?
My camera have -X orientation in world, and moves in YZ plane.

I know max and min coordinates of volume. You can see it on screen above:

  • max - left top nearest point
  • min - right bottom far point

So it’s already limits of room. If some edges (where camera can pass) should be opened, I define opened/closed edges of volume by editable boolean variables in level, and add/subtract 10000 uu to min/max limits.
For example:

  • top edge opened - max Z = max Z + 10000
  • right edge opened - min Y = min Y - 10000

To calculate correct offset for camera in this specific volume I use desired one set in volume parameters, but I need to understand is my screen fits to this volume with this offset or not. Maybe its bigger than I need. And if yes, my offset should be recalculated.
I have compare ratio of this volume and camera aspect ratio:

  • if volume ratio >= camera ratio, so this volume is “horizontal”, in comparison with my screen.
  • if volume ratio < camera ratio, so this volume is “vertical”, in comparison with my screen.

So, if my desired offset = 2000, but it’s not fit screen into volume, it will be recalculated to, for example, 1752.128524, and:

  • in “horizontal” volume camera fits by volume Z, and can move only by Y.
  • in “vertical” volume camera fits by volume Y, and can move only by Z.

Then, to do things correctly, I calculate real screen coordinates in YZ plane:

With it, I can understand than my max and min screen coordinates is in the volume.
And now I can calculate camera position, and clamp it to this max and min of volume.

Also, when your character overlaps volume, you can detect where it happen by hit result.
So, you know exactly which edge you pass, and by booleans like “edge open”, “edge cut” you can create smooth or cut transitions.

How it may be done easier?
For example, if you have really 2d game, with the same camera offset in all rooms, and camera transition between this rooms is always the same (for example smooth), so maybe you can use ray tracing and so on…