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);
如果没找到不会报错。