Skip to content

Instantly share code, notes, and snippets.

@alyatwa
Last active December 15, 2022 19:42
Show Gist options
  • Save alyatwa/7fd0de21a103fe065b0728bdc8bc4ca9 to your computer and use it in GitHub Desktop.
Save alyatwa/7fd0de21a103fe065b0728bdc8bc4ca9 to your computer and use it in GitHub Desktop.
unity snippets

GetCurrentMousePosition GetCurrentMousePosition().GetValueOrDefault();

    private Vector3? GetCurrentMousePosition()
    {
        var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        var plane = new Plane(Vector3.forward, Vector3.zero);

        float rayDistance;
        if (plane.Raycast(ray, out rayDistance))
        {
            return ray.GetPoint(rayDistance);

        }

        return null;
    }

Conveyor Belts Made With Unity

https://www.youtube.com/watch?v=o9RK6O2kOKo
https://i.imgur.com/LXbUxzn.png
https://www.reddit.com/r/Unity3D/comments/nh0hn8/satisfactory_conveyor_belts_made_with_unity/

improve img resolution

https://stackoverflow.com/questions/72927883/why-is-unity-compressing-my-button-image-so-much

change axis position unity

  • create an empty GameObject
  • make the empty GameObject the child of ObjectX
  • reset the Transform of the empty GameObject (it should now center ObjectX)
  • unparent the empty GameObject
  • rotate the empty GameObject so that it's axis are the way you'd like them to be on ObjectX
  • make the empty GameObject the parent of ObjectX

resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment