Unity Notes: Lerping

Just as a reminder to myself:

  • Color.Lerp Interpolates between colors a and b by t.
  • Mathf.Lerp Interpolates between a and b by t. t is clamped between 0 and 1.
  • Color32.Lerp Interpolates between colors a and b by t.
  • Vector2.Lerp Linearly interpolates between two vectors.
  • Vector3.Lerp Linearly interpolates between two vectors.
  • Vector4.Lerp Linearly interpolates between two vectors.
  • Material.Lerp Interpolate properties between two materials.
  • Quaternion.Lerp Interpolates between from and to by t and normalizes the result afterwards.
  • Mathf.LerpAngle Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  • Vector3.Slerp Spherically interpolates between two vectors.
  • Mathf.InverseLerp Calculates the Lerp parameter between of two values.
  • Mathf.MoveTowards
  • Moves a value current towards target.
  • Vector2.MoveTowards
  • Moves a point current towards target.
  • Vector3.MoveTowards
  • Moves a point current towards target.
  • Vector4.MoveTowards
  • Moves a point current towards target.
  • Mathf.MoveTowardsAngle
  • Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
Read More

Daily Unity Notes

PSD Alpha Channel Not Importing Properly

This is one of those answers (to a question about a system that you can manipulate but don’t yet entirely understand) that is so on point and so simple that it not only answers your specific issue, but illuminates how the system works in the first place.

Read More

Daily Unity Notes

Lessons from yesterday:

  • Be sure to use recycling offsets/queues/etc. hao youyong.
  • Still not quite sure I understanding the adding of events to the event manager, at least in terms of why you do something like "GameEventManager.GameOver += GameOver"...

Static stuff:

  • this, because it refers to an object, can't be used in a static method. (Again, because static vars/methods are independent of any object instances.)

Some basic OOP compartmentalization stuff:

  • By putting a manager in between Runner and the GUI, we make both independent of each other. The Runner class doesn't deal with GUI details, only with runner details.
  • If we were to change the GUI – like using icons to display boosts instead of a label – we only need to modifyGUIManager, the rest of the game doesn't care about the change.
  • We could go one step further and not make Runner call the GUI manager at all. Then it would be up to GUIManager to get the boost count from Runner instead. However, then the manager must know details about the runner, which it really shouldn't. Complete decoupling might be achieved by using an event for this, but that's a rather heavy-handed approach for a straightforward case like this. A simple call to a manager is fine.

Finished the Catlikecoding tutorials…awesome!

Read More