Zac_McDonald

Unity C# - IntervalClampUpdate - Helper

Mar 25th, 2017
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. // NOTE: Also needs the IntervalClampUpdate Script: https://pastebin.com/5CfSg4db
  2. public class IntervalClampHelper : MonoBehaviour
  3.     {
  4.         // Needs to be set to run before the default time: Edit/Project Settings/Script Execution Order
  5.  
  6.         #region Public Fields
  7.         #endregion
  8.  
  9.         #region Private Fields
  10.         private IntervalClampUpdate clamper;    // The local interval clamper
  11.         #endregion
  12.  
  13.         #region Unity Methods
  14.         protected void Start ()
  15.         {
  16.             clamper = GetComponent<IntervalClampUpdate>();
  17.         }
  18.  
  19.         protected void FixedUpdate ()
  20.         {
  21.             // Here we reset our world position at the start of the frame this allows
  22.             // for us to modify transform.position while still getting the same clamping effect.
  23.             transform.position = clamper.actualPosition;
  24.         }
  25.         #endregion
  26.  
  27.         #region Public Methods
  28.         #endregion
  29.  
  30.         #region Private Methods
  31.         #endregion
  32.  
  33.     }
Add Comment
Please, Sign In to add comment