Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Start()
- {
- EaseIn();
- }
- void EaseIn()
- {
- easeInDestinationPoint = Vector3.MoveTowards(transform.position, destinationPoint, easeInDistance);
- easeOutDestinationPoint = Vector3.MoveTowards(destinationPoint, transform.position, easeOutDistance);
- iTween.MoveTo(
- gameObject,
- iTween.Hash(
- "position", easeInDestinationPoint,
- "speed", speed,
- "easetype", easeInType,
- "oncompletetarget", gameObject,
- "oncomplete", "LinearMovement"));
- }
- void LinearMovement()
- {
- linearSpeed = Vector3.Distance(transform.position, lastPosition);
- iTween.MoveTo(
- gameObject,
- iTween.Hash(
- "position", easeOutDestinationPoint,
- "speed", (Mathf.Sqrt(linearSpeed)*60f),
- "easetype", iTween.EaseType.linear,
- "oncompletetarget", gameObject,
- "oncomplete", "EaseOut"));
- }
- void EaseOut()
- {
- iTween.MoveTo(
- gameObject,
- iTween.Hash(
- "position", destinationPoint,
- "speed", speed,
- "easetype", easeOutType,
- "oncompletetarget", gameObject,
- "oncomplete", "OnMoveComplete"));
- }
- public float linearSpeed;
- private Vector3 lastPosition = Vector3.zero;
- void LateUpdate()
- {
- lastPosition = transform.position;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement