using System.Collections;
using System.Collections.Generic;
using UnityEngine; //思想:在短时间内在规定圆内随机震动对象位置,从而实现震动效果
public class CamZhengDong : MonoBehaviour {
//震动对象属性
private Transform Tr = null;
//
public float zhenDongShiJian = 6.0f;
//震动幅度
public float fuDu = 10.0f;
//震动对象移动速度
public float speed = 2.0f; // Use this for initialization
void Start () {
Tr = GetComponent<Transform>();
StartCoroutine(CamShake());
} //private void Update()
//{
// if (ElapsedTime < ShakeTime) {
// Vector3 RanPoint = OrigPosition + Random.insideUnitSphere * ShakeAmount;
// Tr.localPosition = Vector3.Lerp(Tr.localPosition, RanPoint, Time.deltaTime * speed);
// //计时
// ElapsedTime += Time.deltaTime;
// }
//} public IEnumerator CamShake() {
float jishi = 0.0f;
Vector3 OrigPosition = Tr.localPosition;
while (jishi < zhenDongShiJian) {
//Random.insideUnitSphere单位圆内随机数
Vector3 RanPoint = OrigPosition + Random.insideUnitSphere * zhenDongShiJian;
Tr.localPosition = Vector3.Lerp(Tr.localPosition,RanPoint,Time.deltaTime * speed);
yield return null;
//计时
jishi += Time.deltaTime;
}
} }

最新文章

  1. javascript遍历算法与技巧
  2. python 之禅
  3. cuda编程基础
  4. ASP.NET 5探险(1):Azure中配置连接字符串、独立项目执行EF7数据迁移
  5. 三、Authentication &amp; sessionid
  6. ZOJ 3811
  7. uva 10474 Where is the Marble? 计数排序
  8. Codeforces Bubble Cup 8 - Finals [Online Mirror] B. Bribes lca
  9. UI进阶 动画
  10. 学习笔记6_Java_day11_JSP_基础和入门(1、2)
  11. [转] 条件变量(Condition Variable)详解
  12. web编程速度大比拼(nodejs go python)(非专业对比)
  13. 安装IntelliJ IDEA JetGroovy(转)
  14. angularjs的directive详解
  15. 爬虫:把廖雪峰的教程转换成 PDF 电子书
  16. 恶补web之一:html学习(2)
  17. 【搬运工】redis 启动和关闭
  18. 2018-11-13 中文代码示例之Programming in Scala学习笔记第二三章
  19. LeetCode算法题-Linked List Cycle(Java实现)
  20. ASP.NET Core中使用Unity5

热门文章

  1. pymongo认证连接
  2. 基于nightmare的美团美食商家爬虫实践
  3. try -catch-finally一些要点
  4. ANR机制
  5. @SafeVarargs注解
  6. 使用KindEditor完成图片上传(springmvc&amp;fastdfs/springmvc&amp;ftp)
  7. 关于function构造函数特别注意的
  8. Linux常用命令之sed(2)
  9. PTA (Advanced Level) 1016 Phone Bills
  10. Linux文件夹打包发送到本地