Hi Everyone,
I am trying to use HOTween to translating a game object to a random location when I press a button. So I do not have a predefined path it is completely dynamic. I did not want to create a new HOTween game object every time the translation occurs because it happens quite often. The only thing that changes is the positional information so I was hoping I could “ResetAndChangeParms” on a persistant Tweener object.
Here is an example of what I am trying to do:
Tweener positionTween = null
TweenParms posTweenParms = null;
void Start()
{
HOTween.Init(true, true, true);
HOTween.EnableOverwriteManager();
posTweenParms = new TweenParms().Prop("localPosition", movingObject.transform.position)
.Ease(EaseType.Linear)
.OnComplete(myCallback).Pause(true).AutoKill(false);
positionTween = HOTween.To(movingObject.transform, 0.0f, posTweenParms);
positionTween.autoKillOnComplete = false;
}
void MoveTo(Vector3 _position)
{
if (HOTween.IsTweening(movingObject.transform ) )
{
positionTween.Complete();
}
positionTween.ResetAndChangeParms(TweenType.To, 0.5f, posTweenParms.NewProp("localPosition", _position).Pause(false));
}
When I call MoveTo(…) once it works fine the HOTween object remains on the object and the positionTween component is fine though the loop says 1/1. When I call it a second time I get this warning:
“HOTween : PlugVector3 is overwriting PlugVector3 for Moving Object (UnityEngine.Transform).localPosition”
And immediately after I get this Error:
“NullReferenceException: Object reference not set to an instance of an object
Holoville.HOTween.Tweener.Update (Single p_shortElapsed, Boolean p_forceUpdate, Boolean p_isStartupIteration, Boolean p_ignoreCallbacks, Boolean p_ignoreDelay)”
Any insight would be appreciated. I know I could just create a new HOTween object and all but I am trying to keep my new calls to a minimum.
Peace