1.OrbitExample
1.1 Trail Renderer 拖尾效果
http://www.ceeger.com/Components/class-TrailRenderer.html
1.2 iTween.DrawPath 通过6个点画圈
void OnDrawGizmos(){
iTween.DrawPath(path);
}
1.3 iTween.MoveTo 设置movetopath:false来做动画循环
void Start(){
iTween.MoveTo(gameObject,iTween.Hash("path",path,"time",1,"easetype",iTween.EaseType.linear,"looptype",iTween.LoopType.loop,"movetopath",false));
}
2.PathControlledCharacter
2.1 GUI Text是如何定位的
http://blog.csdn.net/u010019717/article/details/38655317
- 锚点(Anchor)是指UI本身定位点在哪里
- Postion是针对Screen.width的比例,默认原点再左下角(0,0)
- 通过Pixel Offset定位
- pos(x,y) = (Position.xScreen.width + PixelOffset.x, Position.yScreen.height + PixelOffset.y)
2.2 Light两个属性
- Intensity 强度
- Shadow Type(Hard Shadows) -> Strength 阴影的黑色程度
2.3 Particles粒子系统
- ParticleRenderer 粒子渲染器
在屏幕上渲染粒子。
http://www.manew.com/youxizz/2126.html - ParticleAnimator 粒子动画
粒子动画器随着时间移动你的粒子,你可以使用它们将风、力和颜色循环应用到你的粒子系统中。
http://www.manew.com/youxizz/2098.html - Ellipsoid Particle Emitter 椭球粒子发射器
https://docs.unity3d.com/Manual/class-EllipsoidParticleEmitter.html
2.4 Controller控制 - Input
http://www.ceeger.com/Script/Input/Input.html
2.5 Controller控制 - iTween.PointOnPath
以百分比返回其中的一个坐标
Vector3 coordinateOnPath = iTween.PointOnPath(controlPath,pathPercent);
2.6 Controller控制 - eulerAngles欧拉角
if (characterDirection == Direction.Forward){
lookTarget = iTween.PointOnPath(controlPath, pathPercent + lookAheadAmount);
}else{
lookTarget = iTween.PointOnPath(controlPath, pathPercent - lookAheadAmount);
}
character.LookAt(lookTarget);
float yRot = character.eulerAngles.y;
character.eulerAngles = new Vector3(0, yRot, 0);
- 先获取对应方向上的一个点
- LookAt
- 调整只有y轴转,因为path在上方
转x是物体低头抬头(红),转y是物体摇头(绿),转z是物体倾斜(蓝)
2.7 Controller控制 - 运行逻辑
- DetectKeys来改变iTween路径的百分比,空格来设定y轴一个距离
- FindFloorAndRotation来获取路径上一个点,做好LookAt
- 使用Physics.Raycast,用获取的路径点发射到地板上,避免发射到character,把它里面对象设定在layer=2里。获取坐标
- MoveCharacter里,根据发射的坐标,修改character坐标,实现移动
- 跳跃,空格给与一个向上距离,然后ySpeed被(gravity * Time.deltaTime)减去这个距离,最后判断if(character.position.y
- 移动相机
void MoveCamera(){
iTween.MoveUpdate(
Camera.main.gameObject,
new Vector3(character.position.x,2.7f,character.position.z-5f),
.9f
);
}
3.PathExample
3.1 iTween.DrawPath 画路径
iTween.DrawPath(path);
3.2 iTween.MoveTo -- orienttopath / looktime
- orienttopath 是否朝向路径
- looktime 运动的时间
- lookahead 朝向路径的远点,(0-1)
- looktarget 或朝向其他物体
3.3 iTween.LookUpdate 摄像机朝向物体
iTween.LookUpdate(gameObject,target.position,2);
4.Platforms
4.1 DeathZone
- iTween.CameraFadeAdd , 给摄像机增加一个透明效果
public Texture2D deathFlash;
void Start(){
iTween.CameraFadeAdd(deathFlash,100);
}
- 重生
void OnTriggerEnter(Collider other){
iTween.CameraFadeTo(iTween.Hash("amount",.6,"time",.05));
iTween.CameraFadeTo(iTween.Hash("amount",0,"time",1.6,"delay",.05,"easetype","linear"));
other.GetComponent().Sleep();
other.transform.position=new Vector3(0,8,0);
other.GetComponent().velocity=Vector3.zero;
other.GetComponent().WakeUp();
}
发生碰撞触发
通过iTween.CameraFadeTo,完成镜头闪烁
让球的刚体休眠,设置刚体速度为0,重新启动(实际这里不休眠也行)
4.2 OnCollisionEnter和OnTriggerEnter的区别
http://www.cnblogs.com/flyFreeZn/p/3631590.html
简单说,OnTriggerEnter只要有一方勾选了isTrigger就可以触发,OnCollisionEnter需要双方都没有勾选isTrigger才可以触发
4.3 与地板的触发机制
void OnCollisionStay(Collision collisionInfo){
if(collisionInfo.gameObject.name == "Ground"){
grounded=true;
}
}
void OnCollisionEnter(Collision collisionInfo){
if(collisionInfo.gameObject.name == "Ground"){
grounded=true;
transform.parent=collisionInfo.transform;
}
}
void OnCollisionExit(Collision collisionInfo){
if(collisionInfo.gameObject.name == "Ground"){
transform.parent=null;
grounded=false;
}
}
- OnCollisionStay停留,地板设为true,如果不是true,那么键盘操作是无效的
- OnCollisionEnter,设置父节点(不设置也是可以的)
- OnCollisionExit,离开时地板设为false
4.4 Physics.gravity 重力
http://www.manew.com/youxizz/2158.html
4.5 Rigidbody.angularDrag 角阻力
角阻力可用来减缓物体的旋转。阻力越高旋转越慢。
http://www.manew.com/youxizz/2483.html
4.6 Rigidbody.AddForce给一个刚体加力
GetComponent
http://blog.csdn.net/qq_16318981/article/details/50467819
5.其他收集
5.1 使用x,y
Vector2 buttonSize = new Vector2(120,50);//定义一个Vector2
buttonSize.x//可以使用了
5.2 Cursor.visible指针是否可见
Cursor.visible=false;
5.3 Camera.main.ScreenPointToRay
RaycastHit hit = new RaycastHit();
Ray cameraRay = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast (cameraRay.origin,cameraRay.direction,out hit, 100)) {
iTween.MoveUpdate(arrow.gameObject,hit.point,.9f);
}
- 根据鼠标发射一条射线
- 把箭头的坐标重新定位在hit的新坐标上
http://www.cnblogs.com/xuling/archive/2013/03/04/2943154.html