using System.Collections;
using System.Collections.Generic;
using UnityEngine; public class AnimatorCon : MonoBehaviour {
Animator ani;
// Use this for initialization
void Start () {
ani = GetComponent<Animator>();
} // Update is called once per frame
void Update () {
float h = Input.GetAxis("Horizontal");//控制移动
float v = Input.GetAxis("Vertical");
transform.Translate(h*Time.deltaTime,,v*Time.deltaTime);
if (h<)
{
transform.localScale = new Vector3(-,,);//反向移动
}
else
{
transform.localScale = Vector3.one;
}
if (h!=||v!=)
{
ani.SetBool("IsRun",true);
}
else
{
ani.SetBool("IsRun", false);
}
if (Input.GetKeyDown(KeyCode.Q))
{ ani.SetBool("IsAttack",true);
}
else
{
ani.SetBool("IsAttack", false);
} }
}

2.int类型

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//animator动画状态机int类型的控制
public class DragonControlor : MonoBehaviour {
Animator ani;
// Use this for initialization
void Start () {
ani = GetComponent<Animator>();
}
public void GetButtonQ()
{
ani.SetInteger("com", );//对paiameters进行设置
}
public void GetButtonW()
{
ani.SetInteger("com", -);//对paiameters进行设置
ani.SetInteger("con", );
}
public void GetButtonE()
{
ani.SetInteger("con", -);//对paiameters进行设置
}
// Update is called once per frame
void Update () {
AnimatorStateInfo start = ani.GetCurrentAnimatorStateInfo();//判断当前动画状态
if (start.IsName("dragon_land_on_ground"))
{
ani.SetInteger("com", );//让它返回
}
if (start.IsName("dragon_die"))
{
ani.SetInteger("com", );
}
if (start.IsName("dragon_loop_da_loop"))
{
ani.SetInteger("con", );
}
}
}
AnimatorStateInfo aniSta=  ani.GetCurrentAnimatorStateInfo();//获得当前层的动画片段状态信息
if (h != || v != )
{
ani.SetBool("IsWalk", true);
if (Input.GetKey(KeyCode.LeftShift))
{
ani.SetBool("IsRun", true);
}
else
{
ani.SetBool("IsRun", false);
}
}
else
{
if (aniSta.IsName("run"))//判断是否正在播放此动画
{
ani.SetBool("IsRun", false);
}
ani.SetBool("IsWalk", false);
}

animator 新动画的更多相关文章

  1. Unity3D学习笔记(十六):Animator新动画

    新动画系统: 给模型选择动画类型 普通动画:Generic 人形动画:Humanoid 建立动画控制器 - 在Project右击 - 选择Create-AnimatorContorller 将对应动画 ...

  2. 【Android - 基础】之Animator属性动画

    1      概述 在3.0系统之前,Android给我们提供了逐帧动画Frame Animation和补间动画Tween Animation两种动画: 1)        逐帧动画的原理很简单,就是 ...

  3. Unity 4.0 中的新动画系统——MecAnim

    分享一个文档资料,关于动画系统的,版本应该很老了,但是有借鉴意义的: Unity 4.0 已于 2012 年 11 月 15 日正式发布,Unity 每一次版本的提升,都给游戏开发者带来惊喜,这一次也 ...

  4. (六)Unity5.0新特性------新动画功能

     unity 5.0 中的新动画功能 这里是你能够期待的新动画功能高速概述 ! State Machine Behaviours状态机行为 在Unity 5 中,你会能够将StateMachine ...

  5. 【Android - 进阶】之Animator属性动画

    1.概述 在3.0系统之前,Android给我们提供了逐帧动画Frame Animation和补间动画Tween Animation两种动画: 逐帧动画的原理很简单,就是将一个完整的动画拆分成一张张单 ...

  6. Animator 设置动画效果

    1. 调节预设对象大小适中 2. 设置骨骼,修改关节 3. 拖入预设动作效果对象中 4. 将预设对象拉入场景中,并新建AnimatorController 5. 新建动作或BlendTree,设置参数 ...

  7. CSS3新动画效果

    CSS3添加了几个动画效果的属性,通过设置这些属性,可以做出一些简单的动画效果而不需要再去借助JavaScript.CSS3动画的属性主要分为三类:transform.transition以及anim ...

  8. Android5.0新动画之VectorDrawable

    SVG是前端的一套标准,Vector是在Android中使用,他只是实现了SVG语言的Path的标签 Vector的常用语法   M = moveto(M X,Y): 将画笔移动到指定的坐标位置   ...

  9. Unity动画机制 Animator与Animator Controller教程

    Unity动画机制Animator 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- ...

随机推荐

  1. 创建ReactNative的iOS项目

    http://reactnative.cn/docs/integration-with-existing-apps/ 1.安装好ReactNative开发环境 2.安装好CocoaPods 3.创建项 ...

  2. rtd1296 mtd 设备驱动分析

    mtd 分区一般采用3种方式实现 1.内核写死  mtd_partition 2.u-boot 传参 为了使kernel能够解析mtdparts信息,我们需要将内核中的Device Drivers - ...

  3. ionic cordova screenshot 使用和操作

    如何调用cordova 中的screenshot插件进行截图 首先添加 ionic cordova plugin add com.darktalker.cordova.screenshot npm i ...

  4. AndrewNG Deep learning课程笔记 - RNN

    The Unreasonable Effectiveness of Recurrent Neural Networks,http://karpathy.github.io/2015/05/21/rnn ...

  5. Log4j Append属性指定是否追加内容

    Log4j默认是不断的把日志内容追加到日志文件: 这里就有个属性 Append 默认就是true: 假如我们设置成false 就不追加了 直接覆盖前面的内容: 我们来测试下: log4j.rootLo ...

  6. python操作rabbitMQ小结

    1.安装rabbitMQ(与python无关) https://www.cnblogs.com/libra0920/p/7920698.html 2.python+rabbitMQ实现生产者和消费者模 ...

  7. UITextView设置placeholder

    下面是我的代码,可以直接拿来用 #import <UIKit/UIKit.h> @interface CustomTextView : UITextView @property(nonat ...

  8. UIBezierPath使用

    效果图,Demo的例子是我自己做的,下面曲线的代码是从别处copy过来的 copy地址 -(void)touchesBegan:(NSSet<UITouch *> *)touches wi ...

  9. rsyncd的配置和使用

    服务器端配置文件说明 # /etc/rsyncd: configuration file for rsync daemon mode # See rsyncd.conf man page for mo ...

  10. SQL SERVER 2016研究三

    2016 SQL SEVER 全程加密程式 column encryption setting=Enabled; 重点:需要使用.Net Framework 4.6 新建一个程式如下: 1.创建链接数 ...