Hello.
##Things I want to solve
I am creating a tap game in Unity with reference to the book. When you tap an object using the asset [DoTween] Implemented to add the score by moving the curve. But when you tap the image, The orb is generated, but it does not move up the screen. The score is not added. [DoTween] Why does not work If you know, please answer.
Here is the code
OrbManagar.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
public class OrbManager : MonoBehaviour {
private GameObject gameManager;
public Sprite[] orbPicture = new Sprite [3];
public enum ORB_KIND{
BLUE,
GREEN,
PURPLE,
}
private ORB_KIND orbKind;
// Start is called before the first frame update
void Start() {
gameManager = GameObject.Find ("GameManager");
}
// Update is called once per frame
void Update () {
}
public void FlyOrb () {
RectTransform rect = GetComponent<RectTransform> ();
Vector3[] path = {
new Vector3(rect.localPosition.x * 4.0f, 1100f, 0f),
new Vector3(0f, 1400f, 0f),
};
rect.DOLocalPath (path, 0.5f, PathType.CatmullRom)
.SetEase (Ease.OutQuad)
.OnComplete (AddOrbPoint);
rect.DOScale (
new Vector3 (0.5f, 0.5f, 0f),
0.5f
);
}
void AddOrbPoint () {
switch (orbKind) {
case ORB_KIND.BLUE:
gameManager.GetComponent<GameManager> ().GetOrb (1);
break;
case ORB_KIND.GREEN:
gameManager.GetComponent<GameManager> ().GetOrb (5);
break;
case ORB_KIND.PURPLE:
gameManager.GetComponent<GameManager> ().GetOrb (10);
break;
}
Destroy (this.gameObject);
}
public void SetKind (ORB_KIND kind){
orbKind = kind;
switch (orbKind) {
case ORB_KIND.BLUE:
GetComponent<Image> ().sprite = orbPicture [0];
break;
case ORB_KIND.GREEN:
GetComponent<Image> ().sprite = orbPicture [1];
break;
case ORB_KIND.PURPLE:
GetComponent<Image> ().sprite = orbPicture [2];
break;
}
}
}