- Home /
Raycast for camera follow?
Hi! So I am trying to figure out which function to use for a camera style. It will be an RTS style camera, but I am having it follow a GameObject at a 45 degree angle so when I zoom in/out, it zooms forward toward the object and away. The player moves the object as opposed to the camera directly.
The function I am confused about, though, is to make the object adjust to the terrain accordingly so the camera moves with it as well. I was thinking Raycast but I am not sure if that will work, for example, when I hit a 90 degree angle cliff that is higher than the object itself (I want the object to consistently be a few in game feet off the ground no matter the terrain and the camera will follow accordingly.) any advice on which function I should study up on to accomplish this? If that doesn't make sense, please let me know! This is a tricky cookie to crack.
Edit: I suppose to clarify, what I am wanting is if I am casting from a cube, for example, and the cube is consistently about a foot off the ground and I want it to stay that way permanently, how do I handle Raycasting to move the cube if the cube runs into a 90 degree cliff to go on top of that cliff? And then back down if the cube moves back the other way? Is raycasting the best way to accomplish that? Everything I am reading and watching is saying yes, but I can't quite find anything to help with how to get that written out.