Camera – Unity

Camera.orthographicSize Did you know that the camera is half-size when in orthographic mode? Well I didn’t, but now I do. The orthographicSize property defines the viewing volume of an  orthographic  Camera. In order to edit this size, ensure the Camera is first set to orthographic either through script or in the Inspector. The orthographicSize is half … Read more

Destroy – Unity

public static void Destroy(Object obj, float t = 0.0F); The Unity docs have a good description of the Destroy method here. But in case you just want some quick code here it is. To destroy a gameobject from within itself, just call  Destroy(gameObject); To destroy a gameobject from within after 5 seconds Destroy(gameObject, 5); To destroy a script instance from a gameobject Destroy(this); To … Read more

Invoke – unity

public void Invoke(string methodName, float time); It calls the method methodName in time seconds  This is an alternative to using coroutines.

Mouse Position – Unity

Code to get the Mouse Position in a 2D app Vector3 mPos = Input.mousePosition; mPos.z = -Camera.main.transform.position.z; Vector3 targetPos = Camera.main.ScreenToWorldPoint(mPos);   Then to make something face towards it. yourGameObject.transform.LookAt(targetPos);

Update v FixedUpdate – Unity

Thank you Unity Answers for giving me the low down on this one. Read the full thread HERE eric5h5 gives us a quick answer Update runs once per frame. FixedUpdate can run once, zero, or several times per frame, depending on how many physics frames per second are set in the time settings, and how … Read more

Cross Platform Input Manager – Unity

To use the cross platform input manager you need to make sure you have the Standard Assets Package included in your Unity project. To import it, use these instructions https://docs.unity3d.com/560/Documentation/Manual/AssetPackages.html Ensure that CrossPlatformInput is selected in both the “Editor” and “Standard Assets” folders. Open up the Project Setting > Inputs to define all of the … Read more