新建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 update
void Start()
{
bird = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
bird.velocity = new Vector2(speed, bird.velocity.y);
}
}