日常学习总结的知识点(1)

1.调用预设体时rotation 的理解
Transform.rotation 一个旋转,此时bullet发生了转向,

//调用子弹
m_bullet = Instantiate (m_perfabbullet, m_bulletpos.transform.position, transform.rotation)as GameObject;

把出现的预设体的位置设为子物体,父级旋转,子物体也旋转,子弹运动的方向也是旋转后的。
在bullet上写的脚本里面

//       子弹移动
        transform.position += transform.forward * Time.deltaTime * 30f;

子弹出现后直接按着自己的前方发射。
2 移动

if (Input.GetKey (KeyCode.W)) {//相当于position+=  
    Rig.MovePosition (Rig.position + transform.forward * Time.deltaTime);  
    }  
if (Input.GetKey (KeyCode.S)) {  
    Rig.MovePosition (Rig.position - transform.forward * Time.deltaTime);  
    }  

float hor = Input.GetAxis ("Horizontal");//相当于Rotation*=  
Rig.MoveRotation (Rig.rotation * Quaternion.AngleAxis (hor, Vector3.up));  

3 计时器的种类;
1

m_Timer+=m_CDtime;
if( m_Timer>=m_CDtime ){
m_Timer=0f;
...自己的代码;
}

2 还有一个是
Invoke(方法名称,时间);方法
Invoke(”ReBack“,3f);
这个是调用方法,最好把代码写成一个方法里面。计时调用。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值