Hi, I am struggling to get DOTween to work as i want it.. I am new to Unity and DOTween but i have come from Java libgdx platform. However, I have 3 simple tweens 2 are a sequence and one is a straight up move tween. Code:
void Update ()
{
breathCount = (int)touchCount.breathNumber;
textNum.text = breathCount.ToString ();
if (playedOnce == false) {
PlayTween ();
}
}
public void TransPortObject ()
{
//this.transform.position = new Vector3 (transform.position.x, transform.position.y, 100);
//
DOTween.RestartAll ();
print ("REst the tween has fired.. asif");
}
public void PlayTween ()
{
if (touchCount.state == touchCount.State.START) {
textNumber.DOMove (new Vector3 (transform.position.x, transform.position.y, 100), breathCount);
textNumber.GetComponent<MeshRenderer> ().material.color = new Color (1, 1, 1, 0);
s.Append (textNumber.GetComponent<Renderer> ().material.DOFade (1, touchCount.breathTime / 4));
s.Append (textNumber.GetComponent<Renderer> ().material.DOFade (0, touchCount.breathTime / 4 * 2).SetDelay (touchCount.breathTime / 4));
playedOnce = true;
}
}
Update calls the playTween(); then the transPortObject(); is top reset the Tweens. RestartAll();
But they are not restarting..
I have been over the example scripts to no joy and tried all kinds of resetting the transform position to adding loops yoyo, restart.. and nothing works..
Something is up and i cant figure out how to simple restart the tweens. normal DoMove and 2 sequences.
the transportObject(); is called every time the set variable time is completed.
This is the entire Script:
using UnityEngine;
using System.Collections;
using DG.Tweening;
using UnityEngine.UI;
public class numberScript : MonoBehaviour
{
public Transform textNumber;
public bool playedOnce = false;
public Sequence s;
public TextMesh textNum;
private int breathCount;
void Start ()
{
s = DOTween.Sequence ();
textNumber.GetComponent<MeshRenderer> ().material.color = new Color (1, 1, 1, 0);
//textNumber.GetComponent<Renderer>().material.SetColor()
textNum = gameObject.GetComponent<TextMesh> ();
}
// Update is called once per frame
void Update ()
{
breathCount = (int)touchCount.breathNumber;
textNum.text = breathCount.ToString ();
if (playedOnce == false) {
PlayTween ();
}
}
public void TransPortObject ()
{
//this.transform.position = new Vector3 (transform.position.x, transform.position.y, 100);
//
DOTween.RestartAll ();
print ("REst the tween has fired.. asif");
}
public void PlayTween ()
{
if (touchCount.state == touchCount.State.START) {
textNumber.GetComponent<MeshRenderer> ().material.color = new Color (1, 1, 1, 0);
textNumber.DOMove (new Vector3 (transform.position.x, transform.position.y, 100),touchCount.breathTime);
s.Append (textNumber.GetComponent<Renderer> ().material.DOFade (1, touchCount.breathTime / 4));
s.Append (textNumber.GetComponent<Renderer> ().material.DOFade (0, touchCount.breathTime / 4 * 2).SetDelay (touchCount.breathTime / 4));
playedOnce = true;
}
}
}
please excuse the messy code.
I hope someone can point me in the right direction.. just dont understand why i am having such problems with it.
Thanks