void Start() { HOTween.Init(true, true, true); HOPath path = GetComponent <HOPath>(); TweenParms param = new TweenParms(); param.Prop("position", path.MakePlugVector3Path(), true); param.Loops(-1, type); param.Ease(easeType); HOTween.To(transform, time, param); }
//------------------------------------------------------------------------------------- // Update //------------------------------------------------------------------------------------- void Update() { switch (m_Rno) { case 0: { m_Rno = 1; // jump var parms = new TweenParms(); parms.Prop("position", new Vector3(0, 2, 0), true); parms.Ease(EaseType.EaseInOutQuint); parms.Loops(2, LoopType.Yoyo); m_Tweener = HOTween.To(this.transform, 0.6f, parms); // rolling var parms2 = new TweenParms(); var angle = this.transform.eulerAngles; angle.x += 180.0f; parms2.Prop("eulerAngles", new Vector3(360, 0, 0)); parms2.Ease(EaseType.EaseInOutQuint); HOTween.To(this.transform, 1.2f, parms2); } break; case 1: { if (m_Tweener.isComplete) { m_Rno = 2; m_Timer = 0.10f; } } break; case 2: { m_Timer -= Time.deltaTime; if (m_Timer < 0.0f) { m_Rno = 0; } } break; } }
//------------------------------------------------------------------------------------- // Update //------------------------------------------------------------------------------------- void Update() { switch (m_Rno) { case 0: { m_Rno = 1; var parms = new TweenParms(); parms.Prop("position", new Vector3(0, 2, 0), true); parms.Ease(EaseType.EaseOutExpo); parms.Loops(2, LoopType.Yoyo); m_Tweener = HOTween.To(this.transform, 0.6f, parms); } break; case 1: { if (m_Tweener.isComplete) { m_Rno = 2; m_Timer = 0.10f; } } break; case 2: { m_Timer -= Time.deltaTime; if (m_Timer < 0.0f) { m_Rno = 0; } } break; } }
void Start() { stairPieces = new List <GameObject>(); stairPieceTween = new List <Tweener>(); TweenParms parms = new TweenParms(); parms.Ease(EaseType.EaseInOutExpo); parms.Loops(-1, LoopType.Yoyo); int i = 0; foreach (Transform child in transform.Cast <Transform>().OrderBy(t => t.position.y).Reverse()) { GameObject gameObject = child.gameObject; stairPieces.Add(gameObject); parms.Prop("localPosition", gameObject.transform.localPosition + new Vector3(-5, 0, 0)); parms.Delay(i * 0.2f); Tweener tweener = HOTween.To(gameObject.transform, 1, parms); stairPieceTween.Add(tweener); i++; } }
//creates a new HOTween tween which moves us to the next waypoint //(defined by passed arguments) internal void CreateTween() { //play walk animation if set PlayWalk(); //prepare HOTween's parameters, you can look them up here //http://www.holoville.com/hotween/documentation.html //////////////////////////////////////////////////////////// //create new HOTween plugin for curved paths //pass in array of Vector3 waypoint positions, relative = true plugPath = new PlugVector3Path(wpPos, true, pathtype); //orients the tween target along the path //constrains this game object on one axis if (orientToPath || lockAxis != Axis.None) { plugPath.OrientToPath(lookAhead, lockAxis); } //lock position axis if (lockPosition != Axis.None) { plugPath.LockPosition(lockPosition); } //create a smooth path if closePath was true if (closePath) { plugPath.ClosePath(true); } //create TweenParms for storing HOTween's parameters tParms = new TweenParms(); //sets the path plugin as tween position property if (local) { tParms.Prop("localPosition", plugPath); } else { tParms.Prop("position", plugPath); } //additional tween parameters for partial tweens tParms.AutoKill(false); tParms.Pause(true); tParms.Loops(1); //differ between TimeValue like mentioned above at enum TimeValue //use speed with linear easing if (timeValue == TimeValue.speed) { tParms.SpeedBased(); tParms.Ease(EaseType.Linear); } else { //use time in seconds and the chosen easetype tParms.Ease(easetype); } //create a new tween, move this gameobject with given arguments tween = HOTween.To(transform, originSpeed, tParms); //continue new tween with adjusted speed if it was changed before if (originSpeed != speed) { ChangeSpeed(speed); } }
//creates a new HOTween tween with give arguments that moves along the path private void CreateTween() { //prepare HOTween's parameters, you can look them up here //http://www.holoville.com/hotween/documentation.html //create new plugin for curved paths //pass in array of Vector3 waypoint positions, relative = true plugPath = new PlugVector3Path(waypoints, true, pathType); //orients the tween target along the path if (orientToPath) { plugPath.OrientToPath(lookAhead, lockAxis); } //lock position axis, if set if (lockPosition != Holoville.HOTween.Axis.None) { plugPath.LockPosition(lockPosition); } //create a closed loop, if set if (loopType == LoopType.loop && closeLoop) { plugPath.ClosePath(true); } //create TweenParms for storing HOTween's parameters tParms = new TweenParms(); //sets the path plugin as tween position property tParms.Prop("position", plugPath); //additional tween parameters tParms.AutoKill(false); tParms.Loops(1); if (!moveToPath) { tParms.OnComplete(ReachedEnd); } //differ between TimeValue, use speed with linear easing //or time based tweening with an animation easetype if (timeValue == TimeValue.speed) { tParms.SpeedBased(); tParms.Ease(EaseType.Linear); } else { //use time in seconds and the chosen easetype if (easeType == Holoville.HOTween.EaseType.AnimationCurve) { tParms.Ease(animEaseType); } else { tParms.Ease(easeType); } } //finally create the tween tween = HOTween.To(transform, originSpeed, tParms); //continue new tween with adjusted speed if it was changed before if (originSpeed != speed) { ChangeSpeed(speed); } }