Adding Transform.LookAt2D like it belongs to the Unity API

Unfortunately there is no Transform.LookAt2D in Unity as for now in Unity5. BUT with an extension method this can be added into the API quick and easy!.

Its pretty simple. We just need to have a namespace included wherever we want to use Transform.LookAt2D and thats pretty much!, here’s how:

Lets create the extension method for LookAt2D:

And then we just need to call it from any of our scripts as part of the Transform methods! here’s a quick example:

Quick, easy and clean!

 

 

 

 

One Response to “Adding Transform.LookAt2D like it belongs to the Unity API”

  1. Juan Felipe says:

    Awesomely simple!!!

    Mathematical functions are really clean and easy to read and understand!