unity 物体震动

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

public class ShaiFenJi : MonoBehaviour {
    public GameObject wuTi;//物体
    private C_Model model;
    Vector3 first_pos;
    private float swing = 0.02f;//震动幅度
    // Use this for initialization
    void Start () {
        model = this.GetComponent<C_Model>();
        first_pos = wuTi.transform.localPosition;
    }
    
    // Update is called once per frame
    void Update () {
        if (model.Info ==1)
        {  
            Vector3 pos = first_pos + Random.insideUnitSphere * swing;
            pos.y = wuTi.transform.localPosition.y;
            wuTi.transform.localPosition = pos;
        }
    }
}

亲测可用  !  !  ! 

posted @ 2019-11-04 17:26  剑起苍穹  阅读(686)  评论(0编辑  收藏  举报
/*鼠标点击特效*/