点击位置的动画

时间:2017-07-29 16:12:44

标签: c# unity3d unity5

你能不能帮我弄清楚我试图在角色的头上轻拍动画的错误是什么?问题是这种血液根本就不会出现。

PICTURE

在图片上,您可以看到我已经为角色的头部添加了2个脚本,并从EffectExamples添加了BloodSprayEffect。 以下是这些脚本:

BloodOnTap.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BloodOnTap : MonoBehaviour {

    private static BloodOnTap instance;

    public ParticleSystem bloodEffect;

    void Awake()
    {
        instance = this;
    }


    void Start ()
    {
        if (bloodEffect == null)
            Debug.LogError("Missing Blood Effect");
    }

    public static ParticleSystem MakeBlood(Vector3 position)
    {
        if(instance == null)
        {
            Debug.LogError("There is no SpecialEffect in the scene!");
            return null;
        }
        ParticleSystem effect = Instantiate(instance.bloodEffect) as ParticleSystem;
        effect.transform.position = position;

        Destroy(effect.gameObject, effect.duration);
        return effect;
    }
}

BloodOnTapTouch.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BloodOnTapTouch : MonoBehaviour {


    void Update ()
    {
        for (int i = 0; i < Input.touchCount; i++)
        {
            Touch touch = Input.GetTouch(i);
            if(touch.phase == TouchPhase.Ended && touch.tapCount == 1)
            {
                Vector3 position = Camera.main.ScreenToWorldPoint(touch.position);

                BloodOnTap.MakeBlood((position));
            }
        }
    }
}

我使用了http://pixelnest.io/tutorials/unity-touch-controls/中的代码。

0 个答案:

没有答案