码迷,mamicode.com
首页 > 其他好文 > 详细

任务2

时间:2018-02-04 22:38:45      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:tco   +=   nio   local   rect   this   col   off   mes   

1.

if(Input.GetKeyDown(KeyCode.K)&&rigidbody2D.velocity.y==0){
             rigidbody2D.AddForce(Vector2.up*300f);
             playerAnim.PlayJumpAnim();
             return;
         }

        //控制移动
        float h = Input.GetAxis("Horizontal");
        if(h>0){
            transform.rotation=Quaternion.Euler(new Vector3(0,180,0));
        }else if(h<0){
            transform.rotation = Quaternion.Euler(new Vector3(0,0,0));
        }
        Vector2 v2 = rigidbody2D.velocity;
        if(h !=0){
            playerAnim.PlayWalkAnim();
            rigidbody2D.velocity = new Vector2(h*wallSpeed,v2.y);
            return;
            //控制移动
        }else {
            rigidbody2D.velocity = new Vector2(0,v2.y);
            playerAnim.PlayIdleAnim();
        }
2,碰撞器可以阻挡相机。
3.collider设置成相机的子物体 就无法后退了。
4.c#枚举类型。
5.
using DG.Tweening;动画插件
float offset_x = playerTransform.position.x-transform.position.x;
        if(offset_x > 5f&&transform.position.x !=50f){
transform.DOLocalMoveX(transform.position.x+10f,1.5f);
         if(transform.position.x==30f){
             transform.DOLocalMoveY(5,1f);
         }
        }
6.枚举用法加常用的子弹出来的感觉
public enum ShootDirection {
    Forward,up
}
public class PlayerShoot : MonoBehaviour {
public Transform ForwardPoint;
    public Transform UpPoint;
    public float ShootSpeed = 0.5f;
    
    private float shootTimer=0f;
    // Use this for initialization
    void Start () {
        
    }
    
    // Update is called once per frame
    void Update () {
        shootTimer+=Time.deltaTime;
        if(shootTimer>=ShootSpeed){
            
        }
    }
}
7.
playerShoot=GetComponentInChildren<PlayerShoot>();
8.
v2=new Vector2(0,speed);
         rigidbody2D.velocity=v2;
 
8.
enemy.SendMessage("TakeDamage",SendMessageOptions.DontRequireReceiver);
如果没找到不会报错。
 

任务2

标签:tco   +=   nio   local   rect   this   col   off   mes   

原文地址:https://www.cnblogs.com/xiaomao21/p/8414184.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!