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

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

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

在这里插入图片描述

最近更新

  1. TCP协议是安全的吗?

    2023-12-10 14:26:02       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-10 14:26:02       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-10 14:26:02       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-10 14:26:02       18 阅读

热门阅读

  1. Django大回顾 - 9 Auth模块的使用、缓存

    2023-12-10 14:26:02       38 阅读
  2. tomcat安全基线检查

    2023-12-10 14:26:02       36 阅读
  3. 单例模式【C#】

    2023-12-10 14:26:02       37 阅读
  4. LINQ【C#】

    2023-12-10 14:26:02       32 阅读
  5. C#.net使用npgsql批量写入数据入库到postgresql数据库

    2023-12-10 14:26:02       34 阅读
  6. pytorch 笔记:dist 和 cdist

    2023-12-10 14:26:02       37 阅读
  7. C语言中getchar函数

    2023-12-10 14:26:02       37 阅读
  8. Codeforces Round 912 (Div. 2)补题

    2023-12-10 14:26:02       37 阅读
  9. paddle detection 怎么解析配置文件

    2023-12-10 14:26:02       29 阅读