新建c#脚本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class Fly : MonoBehaviour
{//获取小鸟(刚体)private Rigidbody2D bird;//速度public float speed;// Start is called before the first frame updatevoid Start(){bird = GetComponent<Rigidbody2D>();}// Update is called once per framevoid Update(){bird.velocity = new Vector2(speed, bird.velocity.y);}
}