Unity - A计划(永久有效期) 扫二维码继续学习 二维码时效为半小时

(207评价)
优惠后 ¥1899.00优惠前 ¥2499.00 双十一全年最大力度限时优惠
1对1 答疑即时回复7天无理由退款30天价保提问必答

服务保障

1对1 答疑

提供专属的一对一在线答疑,快速答疑解惑。

即时回复

及时响应学习咨询,帮助解决问题。

7天无理由退款

购买后7天内可申请无理由退款。

30天价保

购买后30天内如遇降价,可申请价保。

提问必答

对于提问做到有问必答,帮您扫清学习过程中的种种障碍

《Dark Wonder》34.巨魔孵化器。
张同学斯基发起了问答2016-10-28
1
回复
960
浏览

    巨魔刚实例化2秒一过,第一个5秒的行走,只有行走动画没有移动。导致第二个巨魔和第一个叠一起了。但是2+5+2秒后,第一个巨魔的第二次和以后行走就正常了。求,第一个行走问题出在哪里(巨魔的优化那个问题我自己解决了,单独一个troll的prefab拿出来是正常的。)   下面是troll的行走优化,我自己改了点,把行走和模型Walk放一起了。孵化器脚本和演示教学的一样。

using UnityEngine;
using System.Collections;

public class troll : MonoBehaviour {
    public bool idle = true;

    private  float timer = 2.0f;
   
    public int  speed =5;

    private Animator anim;

    private CharacterController controller;
   
    void Start ()
    {
        
        anim = GetComponent<Animator>();
        controller = GetComponent<CharacterController>();
    }
    
	void Update ()
    {
        timer -= Time.deltaTime;
        if (timer<=0)
        {
            if (idle )
            {
                idle = false;                    //transform to move
                timer = 5.0f;
                int temp = Random.Range(-90, 90);
                transform.Rotate(new Vector3(0, temp, 0));
               // controller.SimpleMove(transform.forward * speed);
                trollWalk();
            }
            else
            {
                idle = true;                     //transoform to idle
                timer = 2.0f;
                trollidle();
            }
        }
        if (!idle)
        {
            //how to move forward
            // transform.position += transform.forward * Time.deltaTime * speed;
            // controller.SimpleMove(transform.forward*speed);
            trollWalk();
        }
    }
    public void trollWalk()
    {
        anim.SetFloat("run", 0.0F);
        anim.SetFloat("idle", 0F);
        anim.SetFloat("walk", 1.0F);
        controller.SimpleMove(transform.forward * speed);
    }
    public  void trollidle()
    {
        anim.SetFloat("idle", 1F);
        anim.SetFloat("walk", 0.0F);
        anim.SetFloat("run", 0F);
    }
}

 

所有回复
  • siki • 2016-10-29

    因为是一个原因,是你上一个问题的原因,按照我说的把apply root motion取消勾选了,应该没有问题了

    还有-5条回复,点击查看
    你还没有登录,请先登录或注册!
发表回复
你还没有登录,请先 登录或 注册!