Drink water

github

Proving Utilities Repo

I was originally going to make a post about graphs and node based pathfinding but things have been hectic recently. So Instead of a long winded tutorial and a demo, I am just going to write about my helper functions repo.

Repository can be found over here: https://github.com/Math-Man/Proving-Utilities.

Just copy the HTTPS link and add the package through git url in Unity's package manager.

Runtime Methods

Runtime part of the package consists of two helper classes and an IEnumerableExtensions class which impelemnts a rather useful weighted random selection method.

For HelperLibs RGHelper contains methods related to randomness and STHelper contains methods related to positions, monobehaviour Input and Physics. All methods are written to be self descriptive so I am not going to go into individuals methods here but these are some of my favorites that I use in almost every project:

  • STHelper : float Remap(this float value, float from1, float to1, float from2, float to2) : Simply maps a value between a range to another range, always useful.
  • RGHelper : Vector3 RandomPositionOnHemiSphere(Quaternion targetDirection, float angle, float radius, Vector3 offset) Gives a random position on a hemisphere, there is also a circle variant for 2D in the same class. This method doesn't look that useful but I always find myself in need of putting things around a hemi-sphere so there you go.
  • STHelper: Vector3 GetMouseWorldPositionByPlane(Camera camera, Plane plane, bool useDefaultPlane = true) Raycast mouse position from screen to a plane. There are also some, more exotic methods that I've put in these helper methods:
  • RGHelper: List:RaycastHit SphericalUniformRaycast(Vector3 pos, int n, float radius, Vector3 offset, int layermask) Creates a uniform set of raycast on a sphere, useful simulating directed explosions.
  • TextMesh createWorldText(...) Creates a world-text, useful.

Editor (Behaviour) Methods.

Usually these are not just methods but whole behaviour classes. For example I make frequent use of the MovementBehaviour class, It simulates velocity, acceleration etc without having to use a rigidbody and its simple enough to expanded depending on the project.

Another behaviour class I make frequent use of is the Parallax behaviour. Attach this to an object that is attached to the camera. The script shifts the texture depending on the camera position, essentially simulating world-space textures.

I could go into details about the rest of the behaviours but most of it is self explanatory.

The Stats Editor was one of my earlier attempts at creating a dynamic stats manager. Its very old now and Instead of using it I suggest using something like "ScriptableObject Architecture" package. Also the same can be said for the EventNotifier class, just use scriptable objects to serialize events.

Apart from these there is also a couple useful subgraphs under this folder as well. One of them is related to.

I could explain more but to be honest I've just written this summary to document my repo as I'll be using it in my posts and build it up through these posts as well. So that is it for now.