New answers tagged

0

Here's one potential implementation of this behaviour: Quaternion _lastCameraFacing; Vector2 _lastCameraInput; void Start() { _lastCameraFacing = Camera.main.transform.rotation; } void Update() { var input = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")); input = Vector2.ClampMagnitude(input, 1); ...


0

myT.LookAt(target, target.up); tells the camera to look directly at the target. A few options: transform.LookAt(target, Vector3.up); Vector3 rotation = transform.localEulerAngles; rotation.x = 0; //remove x rotation transform.localEulerAngles = rotation; or Vector3 lookTarget = target.position; lookTarget.y = transform.y; //prevents x rotation transform....


0

Thanks for all answers. Here was my solution: The camera is set to have 2 modes (for now). The two modes are: Flight (Fixed Yaw Axis) Regardless of where the camera is looking, yaw is rotated along the global y axis. This was based on the linked post that 'DMGregory' wrote. As you can see from the gif, this has the effect of 'stabilizing' the horizon. ...


3

It seems like you accumulate transformations. What you need to do instead is to keep rotation as euler angles pitch and yaw and then calculate final rotation from them.


0

I solved it. Here is project with working solution: https://gamedev.ru/files/?id=146737 I should to use world_2d instead of world variable. $ViewportMinimap.world_2d = $ViewportMain.world_2d


-1

Try this public Transform target; transform.LookAt(target); attach this to camera


0

The near and far clip planes are already measured in world position units. public struct ClipPlaneDistances { public float fromFarPlane; public float fromNearPlane; } public static ClipPlaneDistances GetDistancesFromClipPlanes(Camera camera, Vector3 point) { Vector3 fromCamera = point - camera.transform.position; float depth = Vector3.Dot(...


2

Not sure why you are doing this "by hand", but it should be pretty straight forward if you use matrices for that. Assume your models are all already transformed to world space, then you usually do the following to get them to clip space: $$ P_c = M_{vc} \cdot M_{wv}\cdot P_w $$ \$P_c\$ is the projected point in clip space. \$M_{vc}\$ is the projection ...


Top 50 recent answers are included