{{ message }}

Instantly share code, notes, and snippets.

# Keith MaggioUtMan88

Created Nov 10, 2019
Create an array of points to be used as turrets, and detect if a point is within a certain angle range.
View ArcDetect.cs
 using System.Collections; using System.Collections.Generic; using UnityEngine; public class ArcDetect : MonoBehaviour { [System.Serializable] public class Turret {
Last active Mar 19, 2019
Originally posted by BakonGuy at Unity Answers: https://answers.unity.com/questions/775784/lerping-euler-angles-make-entire-spin.html, this script helps lerp around angles that potentially pass into the negatives, which would cause objects to spin rapidly.
View AngleLerp.cs
 //Properly Lerp between two angles Vector3 AngleLerp(Vector3 StartAngle, Vector3 FinishAngle, float t) { float xLerp = Mathf.LerpAngle(StartAngle.x, FinishAngle.x, t); float yLerp = Mathf.LerpAngle(StartAngle.y, FinishAngle.y, t); float zLerp = Mathf.LerpAngle(StartAngle.z, FinishAngle.z, t); Vector3 Lerped = new Vector3(xLerp, yLerp, zLerp); return Lerped; }
Created Dec 19, 2018
When the object in the scene becomes enabled, all objects in "observedObjects" will become Enabled/Disabled based on their SetActiveOnEnable flag. Handy for turning things on/off when starting a scene.
View SetActiveOnEnable.cs
 using System.Collections; using System.Collections.Generic; using UnityEngine; public class SetActiveOnEnable : MonoBehaviour { [System.Serializable] public class ObservedObjects { public GameObject gameObject;
Created Oct 9, 2017
Simple 2D Steering Algorithm for Unity.
View Simple2DSteer.cs
 public class SimpleSteerUtility { // This is more of an example to show how the interface functions can be used in a very simple manner. // Or, this can be your one-stop shop for a single function call in your Update function. public static void SimpleSteer(ref Quaternion rotation, // ex: transform.rotation Vector3 dir, // target - position, normalized Vector3 up, // ex: transform.up ref Vector3 velocity, // should be stored in your monobehaviour ref Vector3 position, // ex: transform.position float rotationSpeed,
Created Sep 26, 2017
ArduBoy Mock-Steering (Seek) Algorithm
View Steering.cpp
 struct FPoint { float x; /**< The X coordinate of the point */ float y; /**< The Y coordinate of the point */ }; FPoint steer(const FPoint& target, const FPoint& pos, const FPoint& curForward) { // Direction to target FPoint dir; dir.x = target.x - pos.x; dir.y = target.y - pos.y;
Created Dec 26, 2016
View GizmoIcon.cs
 using UnityEngine; using System.Collections; /// /// This was just a quick-and-dirty tool when inside the Unity Editor. /// Need an Icon on something? Throw this on it, assign a texture (via URI string), done. /// public class GizmoIcon : MonoBehaviour { public string IconFile;
Last active Feb 15, 2020
Unity script that generates random "clouds" (or whatever you want the prefab to be) along an X-Z plane using PerlinNoise.
View CloudGenerator.cs
 using UnityEngine; using System.Collections; /// /// Generates random "clouds" (or whatever you want the prefab to be) along an X-Z plane /// using PerlinNoise. /// public class CloudGenerator : MonoBehaviour { ///
You can’t perform that action at this time.