Hello Chris, hello all,
I'd like to ask you for help on two issues regarding the "looking direction" of the First Person Camera prefab.
The setup: First Person – Touch Screen – Touch controls Turning Only – Camera 3D
The scenario: the player is exactly in the center of a 360° cylinder surrounding him, so by touching he can "look around". There are Hotspots on the cylinder surface, and when tapped upon, the player shall
- face that particular Hotspot (Player Script: Mecanim –Automatic – Turn before walking)
- then move closer to it (Action List: Character Move to Point – Marker to reach – Walk)
This is working, with one exception: the player is not "looking" towards the Hotspot or the Marker to reach (i.e. slightly up or down), he is just turning his body along the Y-axis.
My assumption is that I have to tell the Child Camera of the First Person Player to also adjust its pitch-rotation (= raise or lower his head) while the FPP is turning but I am not sure how to do that.
The second thing: I am using the "Constrain Pitch-Rotation" option of the First Person Player's Child Camera with a setting of +/- 13° which is ideal for these 360° scenes, again with one exception, where I would like to limit it to +/- 9° in a special scene. How would I ideally make that change during runtime?
Thanks in advance!
Best, Jensen
Comments
To have a different pitch limitation, you could do it through script - but it's easier to just drop in your Player prefab into the special scene file. You can then make local changes to that Player, and he'll override the default one (spawned from the Settings Manager) used in all other scenes.
- face that particular Hotspot (Player Script: Mecanim –Automatic – Turn before walking)
- then move closer to it (Action List: Character Move to Point – Marker to reach – Walk) without losing focus.
So actually during the whole movement process I'd like to have the object right in the middle of the screen, like in a camera tracking shot. Imagine observing a mosquito at the opposite wall of your room: you get up from your bed and get slowly closer, around the table and the armchair, but your eyes will never lose track of the mosquito …- Character: Face object (incl. FPS head tilt, Face with body, wait until finished)
- Character: Move to point (wait until finished)
- Character: Face object (incl. FPS head tilt, Face with body, wait until finished) again
That'll take my FP to the right place and have him look into the right direction in the end … but not while he is on his way there.While the FPS head tilt? option works by affecting the First Person Camera, the spin rotation is handled by the character's root - meaning it will compete for control over the character when walking. For this reason, it's not possible to use the two simultaneously.
(For reference, however, the way to get two "Wait until finish" Actions running side-by-side is to precede them with the ActionList: Run in parallel Action)
In a case like this, where you know where the camera's going to begin and end, it's best to rely on either a series of pre-set cameras (and use the Camera: Switch Action to move between them), or a single GameCamera Animated prefab that's set to play an animation when cut to.
Is your player constrained within the cylinder the whole time? It may be easier to rely on camera tricks like this throughout, as the First Person system is really designed for free movement in a more traditional FPS sense.
That the cube blocks you during gameplay is due to collision and is to be expected. However, there's no pathfinding involved - you're attempting to move in a direction and the physics system is preventing you from moving through it.
When it comes to pathfinding, a collider won't change your path like that - you must instead rely on a baked NavMesh. This is just Unity's standard workflow, as NavMesh baking is handled in Unity's Navigation window.
AC can be made to calculate correct pathfinding (i.e. rely on a NavMesh) when using the Character: Move to point Action as you first described. As you hadn't described the need for pathfinding earlier, I suggested the alternatives above.
You could probably go about implementing canned animations for such situations, but it would be a bit tedious.
One thing you could try is to have two cameras on the player - one being the default First Person camera, the other being a GameCamera that is set to look at an invisible "Empty" target. Both cameras at the same position, both immediate children of the player's root.
Then, when moving across the room:
1) Snap the GameCamera's target to the Hotspot (Object: Teleport)
2) Switch to the GameCamera (Camera: Switch)
3) Move the player via pathfinding (Character: Move to point)
4) Switch back to the First Person camera (Camera: Switch)
Haven't tested it myself, and you might find that the First Person camera's orientation isn't correct after switching back, but see if it works otherwise and we'll tweak it.