首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Unity、C#和iTween

Unity、C#和iTween
EN

Stack Overflow用户
提问于 2017-04-24 22:50:50
回答 1查看 867关注 0票数 0

我有一个脚本,使对象旋转时,你点击它。我想看看添加iTween是否会改善运动,但我应该在哪里添加它?

iTween代码:

代码语言:javascript
复制
iTween.RotateBy(gameObject, iTween.Hash("x", .25, "easeType", "easeInOutBack", "loopType", "pingPong", "delay", .4));

脚本:

代码语言:javascript
复制
using UnityEngine;
using System.Collections;

public class rotate : MonoBehaviour {

    public float minX = -360.0f;
    public float maxX = 360.0f;

    public float minY = -3660.0f;
    public float maxY = 360.0f;

    public float sensX = 500.0f;
    public float sensY = 500.0f;

    float rotationY = 0.0f;
    float rotationX = 0.0f;

    void Update () {

        if (Input.GetMouseButton (0)) {
            rotationX += Input.GetAxis ("Mouse X") * sensX * Time.deltaTime;
            rotationY += Input.GetAxis ("Mouse Y") * sensY * Time.deltaTime;
            rotationY = Mathf.Clamp (rotationY, minY, maxY);
            transform.localEulerAngles = new Vector3 (rotationY, -rotationX, 0);
        }
    }
}
EN

回答 1

Stack Overflow用户

发布于 2017-04-24 23:24:30

您的意思是,您希望替换现有的旋转代码来使用这样的iTween函数吗?

代码语言:javascript
复制
void Update () {

    if (Input.GetMouseButton (0)) {
        iTween.RotateBy(gameObject, iTween.Hash("x", .25, "easeType", "easeInOutBack", "loopType", "pingPong", "delay", .4));
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43591336

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档