Suppose I had a building with each floor spaced along the y at 0, 5, 10, 15, etc. I'd like to be able to set the elevation of the camera depending on which floor I want to focus on. I tried setting the ground height to 0, 5, 10, etc respectively, thinking that will recalculate the camera position to be higher, but nothing happened. I did see the Ground Height value change in the Inspector. What is the best way to move the camera elevation to a different floor?
I am using the perspective camera in Rotate Around mode.
Thank you!
Setting the elevation of the perspective camera
Hi Anthony
I don't want to change the ground height, it should stay where it is. I'd like to be able to move the focal point (I believe this is FinalOffset) off the ground. For example, I may want to raise the FinalOffset +5 off the ground, so the Rotate Around camera then orbits around the new focal point. Please see the attached image; it shows the camera as it looks at the FinalOffset which is on the ground (bottom red line). (a) shows the focal point (FinalOffset) raised 5, and so now the camera should pivot around that point, (b) is +5 higher, etc. Basically, a method like SetFocalPointHeight(float) or SetFinalOffsetHeight(float), and the camera is adjusted to rotate around the new point. How can I accomplish that? Thank you!
Image
- Edited
I guess I'm not getting it.
I tried this code:
float camelev = GetStartElevationForFloor(floorIndex);
var targetPos = _perspectiveCamera.FinalOffset;
perspectiveCamera.FocusCamera(new Vector3(targetPos.x, camelev, targetPos.z));
I get the elevation of the current floor (first floor = 0, second = 5, etc), create a focal point at the current focal point with the new elevation and use FocusCamera (alias of MoveCameraTo) to focus on it. The results are a bit erratic. What am I misunderstanding?
I just need a way to adjust the elevation of the focal point. As it is now, if I have a 4th floor, the focal point is still on the first floor...if zoomed in, the camera orbit revolves around the first floor and I can't even see the 4th.
There might be a misunderstanding, the feature SetGroundHeight() is actually meant for going from floor to floor, if you check the demo Change_Ground_Height I represented the ground with a grid, but this a virtual ground, you don't actually change the ground of your 3D model. It's meant to rebase the working Y level of the camera.
Can you share with me a little bit more about the project? a video could be good to understand your intent.
Otherwise, to debug what is happening with you code, can you add the compilation constant "DEBUG_TCP" in your project, and when your function is executed, search in the log for "allowYOffset" you should see "allowYOffset:true" normally. Thanks!