New answers tagged

0

A favorite way to apply camera shake in 2D (or 3D) is to attach the camera's origin to a physics particle, then to attach the physics particle to the focus of the scene with a heavily-damped spring. This allows for adding variable camera shake quite easily, in any direction you want, by adding momentary acceleration (a poke) to the camera's physics particle. ...


0

You should be able to get the effect by disabling mirroring (VRSettings.showDeviceView = false), and then setting up an additional camera that displays to the main window. Make the second camera a child of the VR camera (with the same size, FOV, etc.), and then set up any overlay objects on their own layer that is not viewable to the VR camera.


0

I often like to give myself a little convenience method: Vector3 CameraRelativeFlatten(Vector3 input, Vector3 localUp) { // If this script is on your camera object, you can use this.transform instead. Transform cam = Camera.main.transform; // The first part creates a rotation looking into the ground, // with "up" matching the input ...


0

So the problem you're having is that the Y movement is also used when applying the force. Easiest solution is to simply set the Y movement to 0 when adding the force: rb.AddForce((new Vector3( CameraController.finalMovement.X, 0, CameraController.finalMovement.Z).Normalize() * speed);


2

StarCraft uses a top-down camera. Generally camera types are named based on their projection method and constraints they place on viewing the world. A top-down camera is generally called such because it always sits above the action, looking down. The way you interact with the camera's constraints is usually less of a factor in what we call them. StarCraft'...


0

That's not how your online game will work. When playing on separate computers, you'll still only have one camera active at a time. There will be two instances of the game being run, clients A and B. A will have camera 1 active, B will have camera 2 active. The rest of the game world is synced between the clients. It will be a lot of work to retrofit your ...


1

Everytime you move the sprite, move the camera too. This sounds like it's essentially what you're doing now. If you're encountering performance issues, then you should profile your code to determine where your slow code is. If you're not seeing performance issues, then you don't need to worry about performance issues. Doing a few calculations every frame to ...


0

My guess was right. I just had to pass in the MVP matrix with respect to my target camera. So in unity: void LateUpdate () { _TargetRenderer.sharedMaterial.SetMatrix("_MVPTargetCam", _TargetCam.projectionMatrix *_TargetCam.worldToCameraMatrix * _TargetRenderer.localToWorldMatrix); }


1

scroll value resets when it's not scrolling. For one time scrolling the value turns +/- 0.1f. For multiple time scrolling at a time it changes +/- 0.1f on the current scroll value. Else it resets to Zero on next frame. That's why scrollCount will be used as scroll counter. Two new variables: private float scrollCount = 0f; //scroll count is related to max ...


0

// //Filename: maxCamera.cs // // original: http://www.unifycommunity.com/wiki/index.php?title=MouseOrbitZoom // // --01-18-2010 - create temporary target, if none supplied at start using UnityEngine; using System.Collections; [AddComponentMenu("Camera-Control/3dsMax Camera Style")] public class maxCamera : MonoBehaviour { public Transform target; ...


1

Try changing the camera's orthographic size based on aspect ratio. The larger the orthographic size the farther out it will have "zoomed". For instance, if your camera's orthographic size is 10 normally, when you switch to 16:9 aspect ratio set the orthographic size to a smaller value. Or for perspective camera you can try this


2

Your problem comes from setting the position of the camera in late update. Change your LateUpdate code to something like this and remove the code from Update void LateUpdate() { offset = Quaternion.AngleAxis(Input.GetAxis("Mouse X") * turnSpeed, Vector3.up) * offset; transform.position = player.position + offset; transform....


0

I do not fully understand your issue, however, it may be because you are not scaling your Canvas. You may want to try adding a Canvas Scaler component, and play around with the settings. Possibly set it to Scale with Screen Size, and then set the Match value to 0.5f. If this is not helping, possibly try to provide an animated gif of your issue.


1

give this script to player.this script find camera then give camera.position so you can use Lerp for following using UnityEngine; using System.Collections; public class CameraFollow : MonoBehaviour { void Update () { Vector3 offest = new Vector3 (3,3,3);//Distance from object Vector3 cameraPos = Camera.main.transform.position;//...


0

In the player script, you could find the camera and make it follow the player with: GameObject cam = GameObject.FindWithTag("Camera"); //assuming Camera has tag Camera cam.transform.setParent(this.gameObject); This makes the player the parent of the camera. This essentially does what the drag and drop does, but through code, so it works with prefabs.


1

You want to use GameObject.FindWithTag which will return the first active GameObject in the scene that matches the tag you pass in as the parameter. So assuming your player GameObject uses the tag Player, you would do the following. void Start() { Transform player = GameObject.FindWithTag("Player").transform; }


1

I've solved a problem with a simple logic. Now, When player dies, camera position will be set exact to the player position, thus focusing the camera on player. And after that the orthographic size of the camera will reduced to give it zooming effect. Here is code snippet : IEnumerator ZoomIn() { while (GameCamera.orthographicSize > 2) { yield ...


2

I could not find anything on this subject so I invented my own algorithm which works by iterating over and over again to find more precise results. The higher you set the iteration count, the more precise it will be. hope this helps anyone who has the same problem public Vector3 GetPointClosestTo(Vector3 p, out float result, out int curve) { // an ...


0

Take a look at Viewports. Many of the Viewport subclasses take virtual height and width in their constructors. There are different flavors of viewport depending on how well you want Libgdx to keep to your desired aspect ratio.



Top 50 recent answers are included