unity3d 零散记录2

(1)

f_DeltaTime值。 //自己计算每一帧时间
 
float f_LastFrameRealtime;
 
void Start()
{
f_LastFrameRealtime =  Time.realtimeSinceStartup ;
}
 
void Update()
{
float f_DeltaTime = Time.realtimeSinceStartup - f_LastFrameRealtime;
f_LastFrameRealtime =  Time.realtimeSinceStartup ;
}
 
(2) mecanim系统中 muscle可以控制角色各部位摆动幅度等, 速度为负,动画倒着播放

Vector3 wantedDir = (target.position- anim.rootPosition).normalized; //想要到达的面向
   Vector3 currentDir = anim.rootRotation  * Vector3.forward;//当前面向
   if(Vector3.Dot(currentDir, wantedDir) > 0){//dot cos值>0既在currentDir的前半圆
    anim.SetFloat("Direction", Vector3.Cross(currentDir, wantedDir).y, .25f, Time.deltaTime); 这里在currentDir右边既为正.
    //cross叉乘 ,叉乘向量的y值既,在xz面中,wantedDir在currentdir 的哪个位置,1到-1之间,左手坐标系,四指指向原向量,四指弯曲指向目标向量,大拇指所指方向既为正
   }else{
    anim.SetFloat("Direction",Vector3.Cross(currentDir,wantedDir).y > 0 ? 1 : -1, .25f, Time.deltaTime);
   }
   
   col.Move(anim.deltaPosition);//animator动画的帧位置
  transform.rotation = anim.rootRotation;//根旋转量
  
  
  
  
  
  双击事伯 lasttime   if time - lasttime ><= ....    do sth   lasttime  = time
  
  animator anystate 优先级最高,只要设定了变量,为真,马上执行
            setikposition 可以调制角色不同部位的单独控制,分建不同的层
           
//修改摄像机的cullingMask     
int oldMask = camera.cullingMask;
// change mask
camera.cullingMask = (1 << LayerMask.NameToLayer("TransparentFX")) | (1 << LayerMask.NameToLayer("OtherLayer"));
// do something
// ...
// restore mask
camera.cullingMask = oldMask;     


Profiler 探查窗口 可以查看cpu使用率等     
RenderTexture 摄像机 制作舞台效果

组件右上角,copy component 可以粘贴属性,或复制。

meshrenderer不激活,则物体不显示,但仍然存在,可以碰到

在编辑器选中需要添加碰撞的UITexture对象,给该对象必须要先赋予Texture,直接操作“Alt+Shift+C”,
NGUI会给你计算出一个适合于当前对象的BoxCoillder。如果说该对象已经有一个BoxCoillder,那NGUI会调整它的大小以适应UITexture的大小。
剩下的就是按照自己的需要调整顺序关系。          
右键向深度高的,左键向深度低的

start里面使用协同,可以不用update而按时间执行比如
void Start(){
 StartCoroutine(GoToSleep());
}
IEnumerator GoToSleep(){
 yield return new WaitForSeconds(startCheckInSeconds);
 
 while( sth){
  yield return new WaitForSeconds(checkEverySeconds);
 }
 
 do last sth;
 finish;
}

shader 中加Cull off  不遮挡,背部也能看到

InfiniLearning Game Development With Unity 3D.rar 第六章讲钢体,cloth ragdoll

camera.layerCullDistances   设置各层的fardistance ,可以把小物体放在合适的层,设置distance,离相机多远时不显示小物体

使用协同做时间冷却

direction = transform.TransformDirection(direction); direction本来是世界坐标vector3, TransformDirection(里面基于自身local坐标系)将里面转为世界坐标值.

//摄像机按鼠标左右移动旋转
xAngl += Input.GetAxis ("Mouse X") * xSpeed * 0.02f;
Quaternion camRot = Quaternion.Euler (yAngl, xAngl, 0);
cam.rotation = camRot;


/** 按固定速度旋转
var target: Transform;
var rotateSpeed=30.0;
var t=float;
var q:Quaternion;

var wantedRotation=Quaternion.FromToRotation(transform.position,target.position);
t=rotateSpeed/Quaternion.Angle(transform.rotation,wantedRotation)*Time.deltaTime;
q=Quaternion.Slerp(transform.rotation, target.rotation,t);
transform.rotation=q;
**/

mecanim系统中 ,选中IK PASS OnAnimatorIK()里的对应层的IK动作才能起作用
       anystate代表所有状态都能进入当条件为真时
       
Quaternion.SetLookRotation(z轴朝向的位置,y轴朝向的位置) 返回Quaternion;

当你启动Unity按住ALT键时,可以让你选择所需打开项目。(否则它将尝试更新最后打开的项目)

 请问有没有遇到过 添加了第三方插件SDK之后 如果手机处于待机状态的时候 就会退出APP的情况的呢
北京-KL-程序(1557899269)  下午 18:11:28
有人提过改xml
android:configChanges="orientation|keyboardHidden|navigation|screenSize"


计算那么角色速度角速度。
flota speed  = agent.desiredVelocity.magnitude;
Vector3 velocity = Quaternion.Inver(trnasform.rotation) * agent.desiredVelocity;
float angle = Mathf.Atan2(velocity.x, velocity.z)* 180.0f/3.14159f;
//当有rootMotion的时候OnAnimatorMove回调函数
agent.velocity =animator.deltaPosition/Time.deltatime
transform.rotation = animator.rootRotation;


By default Unity compresses all textures when importing. This can be turned off in the Preferences for faster workflow. But when building a game, all not-yet-compressed textures will be compressed.
默认情况下,Unity会在导入时对纹理进行压缩,为了加速工作,你可以在Preferences里关闭该功能,但是当编译游戏时,所有尚未被压缩纹理都将被重新压缩。

Guitext 屏幕坐标,x:0-1 y:0-1


欧拉角限制 绕y和z 为-180到180,即左右转,和左右倾斜  x为-90到90即前后倾斜

posted on 2013-12-05 13:36  鱼 丸  阅读(685)  评论(0编辑  收藏  举报