船摇晃动画实现

原创
06/23 10:41
阅读数 7
using UnityEngine;
using System.Collections;

public class FightSCShipWobble : MonoBehaviour
{
    private Vector3 _p;
    private float _t;
    private float _tx;
    private float _ty;
    private float _tz;

    public Vector3 angle;
    public float y;

    private void Awake()
    {
        _p = transform.localPosition;
        _t = UnityEngine.Random.Range(0f, 3f);
        _tx = UnityEngine.Random.Range(0f, 3f);
        _ty = UnityEngine.Random.Range(0f, 3f);
        _tz = UnityEngine.Random.Range(0f, 3f);
    }

    // Use this for initialization
    private void Start()
    {
    }

    // Update is called once per frame
    private void Update()
    {
        transform.localPosition = _p + new Vector3(0, y * Mathf.Sin(Time.time + _t), 0);
        transform.localEulerAngles = new Vector3(angle.x * Mathf.Sin(Time.time + _tx), angle.y * Mathf.Sin(Time.time + _ty), angle.z * Mathf.Sin(Time.time + _tz));
    }
}

 

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
在线直播报名
返回顶部
顶部