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);
    }
}

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

相关推荐
auccy11 小时前
Unity Sprite 添加法线贴图
unity·贴图·normal
一锅炖出任易仙11 小时前
创梦汤锅学习日记day32
学习·ai·游戏引擎
mxwin14 小时前
次世代角色 PBR 贴图制作 + Unity URP 接入 极简流程图
unity·流程图·贴图·shader
mxwin15 小时前
Unity URP 法线贴图如何生成 用什么工具创建
unity·游戏引擎·贴图
mxwin1 天前
Unity URP 法线贴图色彩空间、编码与解码
unity·游戏引擎·贴图·shader
玖玥拾1 天前
Cocos学习笔记:项目框架搭建与异步加载进度
游戏引擎·cocos2d
mxwin1 天前
Unity Shader URP:将法线可视化,便于调试
unity·游戏引擎·shader
蓝黑墨水1 天前
unity相关链接
unity·游戏引擎
mxwin1 天前
Unity Shader 法线贴图的七种错误用法
unity·游戏引擎·贴图·shader
mxwin1 天前
Unity URP 切线空间详解
unity·游戏引擎·shader