UnityCommunity/UnityLibrary

Add 2D Follow Script

hasanbayatme opened this issue ยท 7 comments

Follow Utility.

We should be able to attach it to any object that we want follows another object.

This follow script can have these settings:

  • offset (Vector3): The position offset for the follower.
  • followType (Enum): MoveTowards, Lerp, SmoothDamp and Acceleration Enum, Also each follow type has it's own settings.
public enum FollowType {
  MoveTowards,
  Lerp,
  Slerp,
  SmoothDamp,
  Acceleration
}
  • speed (You can use it where you need it): The speed of the follower.
  • time (You can use it where you need it for Lerp, MoveTowards, ...): The time for movement, Also you can use it as smooth time for SmoothDamp.
  • bounds (Bounds, BoxCollider2D, Vector2, ...): Can be anything, a width and height or a box collider 2d or an bounds class, also there should be an option to disable it.

EDIT: Acceleration movement http://answers.unity3d.com/answers/29757/view.html

Any more suggestions are welcome. ๐Ÿ˜„

Looking for Rigidbody2D follow script? Find it at #13

Thanks.

Sounds like a fun thing to check, I'll give it a try today.

Added a sample on last commit, I'm not sure what you mean by acceleration follow, will add if explained.

Acceleration follow means the object increases speed over time. Gradually moving an object.

Here is a nice resource: http://answers.unity3d.com/answers/29757/view.html

Resource Added to issue.

Thanks.

The script was added in commit 6f5c171
It's called Follow2D
Just missing the acceleration follow.

I know.

But we are waiting for acceleration follow to be added, then we close this issue.

Thanks.

Added the acceleration follow in 711f635

Nice job.