unity 2d 入门 飞翔小鸟 飞翔脚本(五)

新建c#脚本

csharp 复制代码
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);
    }
}

将脚本拉动至小鸟图层里面

相关推荐
Hody9112 小时前
【XR开发系列】Unity第一印象:编辑器界面功能布局介绍(六大功能区域介绍)
unity·编辑器·xr
lrh302518 小时前
Custom SRP - 14 Multiple Cameras
unity·渲染管线·srp
AA陈超1 天前
虚幻引擎5 GAS开发俯视角RPG游戏 P07-11 实现自动运行
c++·游戏·ue5·游戏引擎·虚幻
Hody912 天前
【XR开发系列】Unity下载与安装详细教程(UnityHub、Unity)
unity·游戏引擎·xr
程序员正茂2 天前
在Unity3d中使用Netly开启TCP服务
unity·tcp·netly
Little丶Seven2 天前
使用adb获取安卓模拟器日志
android·unity·adb·个人开发
雪下的新火3 天前
Blender-一个简单的水
游戏引擎·blender·特效制作·笔记分享
黄思搏3 天前
Unity坐标转换指南 - 3D与屏幕UI坐标互转
ui·3d·unity
weixin_424294673 天前
在 Unity 游戏开发中,为视频选择 VP8 还是 H.264
unity·游戏引擎
一步一个foot-print4 天前
【Unity】Light Probe 替代点光源给环境动态物体加光照
unity·游戏引擎