资源简介
Unity3d非物理引擎模拟碰撞效果,做了开放修改,可以在u3d的编辑面板改属性,属性建议值在图片中
代码片段和文件信息
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class People : MonoBehaviour {
public int Name;
public float SafeDisatance;
public float DangerDistance;
public float EachDisForce;
public float XMax=10;
public float XMin=-10;
public float ZMax=10;
public float ZMin=-10;
public int ToleCount = 0;
Vector3 Zero = new Vector3(000);
Vector3 Fit = new Vector3(0.5f00.5f);
Vector3 speed=new Vector3();
// public List QiTaRen = new List();//1111111111111111111111111111
public List QiTaRenNum = new List();//222222222222222222222222222
public List NeedToThink = new List();
//public PeopleRoot Root=PeopleRoot.GetInstance();
void ChooseNeedToThink()
{
Vector3 ThisPos=this.gameobject.transform.position;
Vector3 OtherPos;
//#region 很大的性能开销
//for (int i = 0; i < QiTaRen.Count; i++)
//{
// OtherPos = QiTaRen[i].transform.position;
// if (Vector3.Distance(ThisPos OtherPos) < SafeDisatance)
// {
// NeedToThink.Add(i);
// }
//}
//#endregion
#region 鬼畜的开始
for (int i=0;i {
// OtherPos = PeopleRoot.GetInstance().PeoplePile[QiTaRenNum[i]].gameobject.transform.position;
OtherPos = PeopleRoot.GetInstance().PeoplePileSingleMode[QiTaRenNum[i]].gameobject.transform.position;
if (Vector3.Distance(ThisPos OtherPos) < SafeDisatance)
{
NeedToThink.Add(i);
}
}
#endregion
}
Vector3 CalculateSinglePower(Vector3 Other)
{
Vector3 Force;
float Power =((SafeDisatance-DangerDistance) -Vector3.Distance(this.gameobject.transform.position Other))/ (SafeDisatance - DangerDistance)*EachDisForce;
Force.x = Other.x - this.gameobject.transform.localPosition.x;
if(Force.x>0)
{
Force.x = 0.1f*Power;
}
else
{
Force.x = -0.1f*Power;
}
Force.y = 0;
Force.z = Other.z - this.gameobject.transform.localPosition.z;
if (Force.z > 0)
{
Force.z = 0.1f*Power;
}
else
{
Force.z = -0.1f*Power;
}
return Force;
}
Vector3 CalculateNeed()
{
Vector3 All=new Vector3(000);
Vector3 Temp;
//#region 很大的性能开销
//for (int i=0;i //{
// Temp=CalculateSinglePower(QiTaRen[NeedToThink[i]].gameobject.transform.position);
// All.x += Temp.x;
// All.z += Temp.z;
//}
//#endregion
#region 鬼畜的计算
for (int i = 0; i < NeedToThink.Count; i++)
{
// Temp = CalculateSinglePower(PeopleRoot.Ge
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 98167 2017-08-12 14:46 小球相撞\2017812-144557.jpg
文件 111787 2017-08-12 14:46 小球相撞\2017812-144631.jpg
文件 6519 2017-08-11 16:57 小球相撞\People.cs
文件 2529 2017-08-11 16:57 小球相撞\PeopleRoot.cs
文件 46 2017-08-12 14:43 小球相撞\说明.txt
目录 0 2017-08-12 14:46 小球相撞
----------- --------- ---------- ----- ----
219048 6
- 上一篇:PID控速小车
- 下一篇:spring-cloud demo
相关资源
- Unity3D4.6.3P4+破解文件+UVS插件联动VS编
- unity3d闪烁高亮page包
- NWH Vehicle Physics.txt
- 武士2复仇源码
- unity3d跑酷游戏源码
- 恐怖密室++精细场景模型,高质量灯光
- Unity3d动态创建excel以及写入数据
- Unity5.X从入门到精通可复制超高清版本
- unity3D镜面反射3种shader
- AngryBots unity3D源码版带资源
- Unity3d 插件 破碎效果 MeshExplosion
- unity3d最全面试题
- Haste Pro v1.8.6
- Unity3dforPsv开发资源和教程
- Unity3D的传送带工程实现
- 网狐U3D旗舰版源码全套包含服务器端
- Unity3d实现的十字路口的模拟
- Unity3D客户端PureMVC框架视屏讲解
- unity3d斗地主
- Unity4.x从入门到精通课本及源码
- Shader编程教程 完整
- Unity3d视频教程
- [手游] Unity3D《最后一战》全套完整源
- Unity3D_4.x_5.x全系列通用一键破解工具
- SUIMONO Water System v2.1.6最新版
- Unity3D一个打地鼠游戏的De‘moemo
- Unity3d ShaderLab开发实战详解pdf+源码
- Unity3D图表插件——柱状图、折
- Unity3D中文api开发手册
- Unity3D5.6201720182019中文版本语言包.ra
评论
共有 条评论