国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Unity之創(chuàng)建第一個(gè)2D游戲項(xiàng)目

這篇具有很好參考價(jià)值的文章主要介紹了Unity之創(chuàng)建第一個(gè)2D游戲項(xiàng)目。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

一 Unity環(huán)境配置

1.1 Untity資源官網(wǎng)下載:https://unity.cn/releases

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

1.2 Unity Hub集成環(huán)境,包含工具和項(xiàng)目的管理

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

1.3 Unity Editor編輯器

unity創(chuàng)建項(xiàng)目,unity,游戲引擎1.4?Visual Studio 2022腳本編輯器

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

1.5 AndroidSKD,JDK,NDK工具,用于android環(huán)境的運(yùn)行

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

二 創(chuàng)建Unity項(xiàng)目

2.1 新建2D模板項(xiàng)目unity創(chuàng)建項(xiàng)目,unity,游戲引擎

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

2.2 新建2D物體

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

2.3 新建C#腳本文件?

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

2.4 腳本文件拖拽到物理區(qū)域,關(guān)聯(lián)物體?

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

2.5 點(diǎn)擊腳本打開(kāi)?Visual Studio 進(jìn)行編輯

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

2.6 輸入Debug.Log(gameObject.name);獲取物體的名字,點(diǎn)擊運(yùn)行?

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

2.7 調(diào)試?,腳本文件保存后,可以看到UnityEditor里面的腳本文件會(huì)同步變化

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

2.9 點(diǎn)擊頂部運(yùn)行按鈕就可以在控制臺(tái)看到日志輸出信息,可以看到打印出了物理對(duì)象的名字和標(biāo)簽

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

三 運(yùn)行問(wèn)題

3.1?第一次運(yùn)行可能會(huì)出現(xiàn)錯(cuò)誤,顯示Unity腳本顯示“雜項(xiàng)文件”,并且無(wú)語(yǔ)法提示的問(wèn)題

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

3.2? 解決方法:點(diǎn)擊 編輯(Edit)>首選項(xiàng)(Preferences)打開(kāi)首選項(xiàng)窗口?

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

3.3 在首選項(xiàng)窗口中,選擇 外部工具(External Tools)選項(xiàng)卡,將 外部腳本編輯器(External Script Editor)的設(shè)置改為 Visual Studio 2019等編輯器?unity創(chuàng)建項(xiàng)目,unity,游戲引擎

3.4 可以看到語(yǔ)法能夠正常顯示了?

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

四,物體組件認(rèn)識(shí)

4.1? 一個(gè)物理有很多組件,點(diǎn)擊物理,默認(rèn)組件信息就會(huì)出來(lái)

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

4.2 如下可以給物理新加組件信息,比如給物體新加聲音組件

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

4.3 腳本關(guān)聯(lián)物體后,也也屬于物體的一個(gè)組件?,可以在腳本中獲取物體的其它組件和控制物體的組件

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

4.4? 物體下面還可以創(chuàng)建多個(gè)物體,我們創(chuàng)建一個(gè)膠囊子物體,那膠囊就屬于子組件

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

4.5 腳本獲取基礎(chǔ)組件和子組件,父組件。如下獲取物體和組件實(shí)例:

using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;

public class main : MonoBehaviour
{
    public GameObject Capsule;//膠囊組件
    public GameObject Prefab;//預(yù)設(shè)體
    // Start is called before the first frame update
    void Start()
    {

        //拿到當(dāng)前腳本所掛載的游戲物體
        //GameObject go = this.gameObject;
        //名稱
        UnityEngine.Debug.Log(gameObject.name);
        //tag
        UnityEngine.Debug.Log(gameObject.tag);
        //layer
        UnityEngine.Debug.Log(gameObject.layer);

        //膠囊的名稱
        UnityEngine.Debug.Log(Capsule.name);
        //膠囊當(dāng)前真正的激活狀態(tài)
        UnityEngine.Debug.Log(Capsule.activeInHierarchy);
        //膠囊當(dāng)前自身激活狀態(tài)
        UnityEngine.Debug.Log(Capsule.activeSelf);

        //獲取Transform組件
        //Transform trans = this.transform;
        UnityEngine.Debug.Log(transform.position);

        //獲取其他組件
        BoxCollider bc = GetComponent<BoxCollider>();
        //獲取當(dāng)前物體的子物體身上的某個(gè)組件
        GetComponentInChildren<CapsuleCollider>(bc);
        //獲取當(dāng)前物體的父物體身上的某個(gè)組件
        GetComponentInParent<BoxCollider>();
        //添加一個(gè)組件
        Capsule.AddComponent<AudioSource();
        //通過(guò)游戲物體的名稱來(lái)獲取游戲物體
        //GameObject test = GameObject.Find("Test");
        //通過(guò)游戲標(biāo)簽來(lái)獲取游戲物體
        GameObject test = GameObject.FindWithTag("Enemy");
        test.SetActive(false);
        UnityEngine.Debug.Log(test.name);
        //通過(guò)預(yù)設(shè)體來(lái)實(shí)例化一個(gè)游戲物體
        GameObject go = Instantiate(Prefab, Vector3.zero, Quaternion.identity);
        //銷毀
        Destroy(go);
    }

    // Update is called once per frame
    void Update()
    {
   
    }
}

五 鼠標(biāo)和觸摸事件

5.1 鼠標(biāo)事件

using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;
using UnityEngine.Windows;
using Input = UnityEngine.Input;

public class main : MonoBehaviour
{

    void Start()
    {
    }

    // Update is called once per frame
    void Update()
    {
        //鼠標(biāo)的點(diǎn)擊
        //按下鼠標(biāo) 0左鍵 1右鍵 2滾輪
        if (Input.GetMouseButtonDown(0)){
            UnityEngine.Debug.Log("按下了鼠標(biāo)左鍵");
        }
        //持續(xù)按下鼠標(biāo)
        if (Input.GetMouseButton(0)) {
        UnityEngine.Debug.Log("持續(xù)按下鼠標(biāo)左鍵");
        }
        //抬起鼠標(biāo)
       if (Input.GetMouseButtonUp(0)) {
            UnityEngine.Debug.Log("抬起了鼠標(biāo)左鍵");
        //按下鍵盤按鍵
        }
        if (Input.GetKeyDown(KeyCode.A)) {
            UnityEngine.Debug.Log("按下了A");
                }
        //持續(xù)按下按鍵
        if (Input.GetKey(KeyCode.A)) {
            UnityEngine.Debug.Log("持續(xù)按下A");
         }
        //抬起鍵盤按鍵
        if (Input.GetKeyUp("a")){
           UnityEngine.Debug.Log("松開(kāi)了A");
        }
    }
}

5.2 保存運(yùn)行后可以看到控制臺(tái)有對(duì)應(yīng)的日志輸出

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

5.3 手機(jī)單點(diǎn),多點(diǎn)觸控、

using UnityEngine;
using Input = UnityEngine.Input;

public class main : MonoBehaviour
{

    void Start()
    {
        //開(kāi)啟多點(diǎn)觸控
        Input.multiTouchEnabled = true;
    }

    // Update is called once per frame
    void Update()
    {
        //判斷單點(diǎn)觸摸
        if (Input.touchCount == 1)
        {
            //觸摸對(duì)象
            Touch touch = Input.touches[0];//觸摸位置
            UnityEngine.Debug.Log(touch.position);//觸摸階段
            switch (touch.phase)
            {
                case UnityEngine.TouchPhase.Began:

                    break;
                case UnityEngine.TouchPhase.Moved:

                    break;
                case UnityEngine.TouchPhase.Stationary:

                    break;
                case UnityEngine.TouchPhase.Ended:

                    break;
                case UnityEngine.TouchPhase.Canceled:

                    break;
            }
        }

        //判斷單點(diǎn)觸摸
        if (Input.touchCount == 2)
        {
            //觸摸對(duì)象1
            Touch touch0 = Input.touches[0];
            //觸摸對(duì)象1
            Touch touch1 = Input.touches[1];
        }
    }
}

5.4 物體向量移動(dòng),添加物體控制組件

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

編寫向量移動(dòng)腳本

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlarerControll : MonoBehaviour
{
    public CharacterController characterController;
    // Start is called before the first frame update
    void Start()
    {
        characterController = GetComponent<CharacterController>();
    }

    // Update is called once per frame
    void Update()
    {
        //水平軸
        float horizontal = Input.GetAxis("Horizontal");
        //垂直軸
        float vertical = Input.GetAxis("Vertical");
        //創(chuàng)建成一個(gè)方向向量
        Vector2 dir = new Vector2(horizontal,vertical);
        Debug.DrawRay(transform.position, dir, Color.red);
        characterController.SimpleMove(dir);
    }
}

六?鼠標(biāo)控制物體移動(dòng)

6.1 2D用transform屬性控制移動(dòng)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlarerControll : MonoBehaviour
{
    public CharacterController characterController;
    // Start is called before the first frame update
    void Start()
    {
        characterController = GetComponent<CharacterController>();
    }


    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButton(0))
        {
           
            //目前的鼠標(biāo)二維坐標(biāo)轉(zhuǎn)為三維坐標(biāo)
            Vector2 curMousePos = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
            //目前的鼠標(biāo)三維坐標(biāo)轉(zhuǎn)為世界坐標(biāo)
            curMousePos = Camera.main.ScreenToWorldPoint(curMousePos);
       
           transform.position = curMousePos ;

        }
    }
}

6.2 在攜程里面控制物體移動(dòng)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlarerControll : MonoBehaviour
{

    // Start is called before the first frame update
    void Start()
    {
       
      StartCoroutine(OnMouseDown());//在Start方法中調(diào)用StartCoroutine(要調(diào)用的協(xié)程方法)
    }

    // Update is called once per frame
    void Update()
    {
 
    }

    //協(xié)程
    IEnumerator OnMouseDown()
    {
        //1. 得到物體的屏幕坐標(biāo)
        Vector3 cubeScreenPos = Camera.main.WorldToScreenPoint(transform.position);

        //2. 計(jì)算偏移量
        //鼠標(biāo)的三維坐標(biāo)
        Vector3 mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, cubeScreenPos.z);
        //鼠標(biāo)三維坐標(biāo)轉(zhuǎn)為世界坐標(biāo)
        mousePos = Camera.main.ScreenToWorldPoint(mousePos);
        Vector3 offset = transform.position - mousePos;

        //3. 物體隨著鼠標(biāo)移動(dòng)
        while (Input.GetMouseButton(0))
        {
            //目前的鼠標(biāo)二維坐標(biāo)轉(zhuǎn)為三維坐標(biāo)
            Vector3 curMousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, cubeScreenPos.z);
            //目前的鼠標(biāo)三維坐標(biāo)轉(zhuǎn)為世界坐標(biāo)
            curMousePos = Camera.main.ScreenToWorldPoint(curMousePos);

            //物體世界位置
            transform.position = curMousePos + offset;
            yield return new WaitForFixedUpdate(); //這個(gè)很重要,循環(huán)執(zhí)行
        }
    }
}

6.3 用Translate滑動(dòng)鼠標(biāo)移動(dòng)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlarerControll : MonoBehaviour
{
   
    // Start is called before the first frame update
    void Start()
    {
     
    }

    // 定義了一個(gè)名為sizespeed的公共(public)浮點(diǎn)型(float)變量,初始值為1
    public float sizespeed = 1;
    // 定義了一個(gè)名為mouseSpeed的公共浮點(diǎn)型變量,初始值為10
    public float mouseSpeed = 10;  

    // 定義了一個(gè)名為lastMousePosition的私有(private)Vector3類型變量
    private Vector3 lastMousePosition;    

    // Update is called once per frame
    void Update()
    {
        // 獲取鼠標(biāo)滾輪的輸入值,并將其賦值給名為mouse的局部(local)浮點(diǎn)型變量
        float mouse = -Input.GetAxis("Mouse ScrollWheel");   

        // 鼠標(biāo)中鍵按住拖動(dòng)
        if (Input.GetMouseButton(0))
        {   
            // 獲取當(dāng)前鼠標(biāo)位置和上一次鼠標(biāo)位置之間的差值,并將其賦值給名為deltaMousePosition的局部Vector3類型變量
            Vector3 deltaMousePosition = Input.mousePosition - lastMousePosition;
            // 將攝像機(jī)的位置向左右和上下移動(dòng),移動(dòng)的距離由鼠標(biāo)的移動(dòng)距離和鼠標(biāo)速度決定
            transform.Translate(deltaMousePosition.x * mouseSpeed * Time.deltaTime, deltaMousePosition.y * mouseSpeed * Time.deltaTime, 0);    

        }
        // 將攝像機(jī)的位置向上或向下移動(dòng),移動(dòng)的距離由鼠標(biāo)滾輪的輸入值和大小速度決定
        transform.Translate(new Vector3(0, mouse * sizespeed, 0) * Time.deltaTime, Space.World);
        // 將鼠標(biāo)當(dāng)前位置賦值給lastMousePosition變量,以便下一幀計(jì)算鼠標(biāo)位置差值
        lastMousePosition = Input.mousePosition;    

    }
}

七 向量的認(rèn)識(shí)

7.1 向量在游戲角色世界是非常重要的一個(gè)概念,上面大部分物體的移動(dòng)都是通過(guò)向量Vector3?

7.2?向量指一個(gè)同時(shí)具有大小和方向的量. 它通常畫(huà)為一個(gè)帶箭頭的線段(如下圖).線段的長(zhǎng)度可以表示向量的大小,而向量的方向也就是箭頭所指的方向.物理學(xué)中的位移、速度、力等都是矢量

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

7.3?只要向量的大小和方向相同, 即視為相等的向量, 如下圖所示都是相同的向量.

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

7.4?向量的加法可以用幾種三種法則來(lái)解釋, 比如下面的三角形法則

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

7.5?向量的減法也有類似運(yùn)算法則, 三角形法則和平行四邊形, 記得箭頭總是由減數(shù)指向被減數(shù):

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

7.6?向量 b 與一個(gè)標(biāo)量(實(shí)數(shù))相乘還是一個(gè)向量, 觀察下面的當(dāng)標(biāo)量改變時(shí)候, 向量 a 的變化:

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

八 示例,碰撞物體

8.1 創(chuàng)建一個(gè)角色

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

8.2 給角色添加剛體和碰撞體,把重力設(shè)為0,不然會(huì)向下移動(dòng)出場(chǎng)景

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

8.3 新建紅色障礙物碰撞體,同時(shí)也添加碰撞體

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

?8.3? 在腳本里面編寫鍵盤按鍵控制物體移動(dòng)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MyPlayer : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    public float speed = 5f;//移動(dòng)速度
    void Update()
    {
        float moveX = Input.GetAxisRaw("Horizontal");//控制水平移動(dòng)方向 A:-1 D:1 0
        float moveY = Input.GetAxisRaw("Vertical");//控制垂直移動(dòng)方向 W: 1 S:-1 0
        Vector2 position = transform.position;
        position.x += moveX * speed * Time.deltaTime;
        position.y += moveY * speed * Time.deltaTime;
        transform.position = position;
    }
}

8.5 運(yùn)行可以看到碰撞到障礙物停止的效果

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

8.6 優(yōu)化,發(fā)現(xiàn)角色碰到物體會(huì)抖動(dòng)和旋轉(zhuǎn),旋轉(zhuǎn)需要勾選上腳色剛體的旋轉(zhuǎn)約束屬性

unity創(chuàng)建項(xiàng)目,unity,游戲引擎

8.7 抖動(dòng)問(wèn)題需要編寫腳本,用剛體的移動(dòng)替換腳色的移動(dòng),修改如下:文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-757214.html

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MyPlayer : MonoBehaviour
{

    public Rigidbody2D rbody;

    // Start is called before the first frame update
    void Start()
    {
        rbody = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    public float speed = 10f;//移動(dòng)速度
  
    void Update()
    {
        float moveX = Input.GetAxisRaw("Horizontal");//控制水平移動(dòng)方向 A:-1 D:1 0
        float moveY = Input.GetAxisRaw("Vertical");//控制垂直移動(dòng)方向 W: 1 S:-1 0
        Vector2 position = rbody.position;
        position.x += moveX * speed * Time.deltaTime;
        position.y += moveY * speed * Time.deltaTime;
        //transform.position = position;
        rbody.MovePosition( position);
    }
}

到了這里,關(guān)于Unity之創(chuàng)建第一個(gè)2D游戲項(xiàng)目的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 【Unity】Unity開(kāi)發(fā)學(xué)習(xí)和項(xiàng)目實(shí)踐02——?jiǎng)?chuàng)建第一個(gè)Unity項(xiàng)目和游戲物體

    【Unity】Unity開(kāi)發(fā)學(xué)習(xí)和項(xiàng)目實(shí)踐02——?jiǎng)?chuàng)建第一個(gè)Unity項(xiàng)目和游戲物體

    創(chuàng)建第1個(gè)Unity項(xiàng)目 打開(kāi)Unity hub,點(diǎn)擊新項(xiàng)目 以下有四處地方需要注意選擇: 1.Unity編輯器版本 2.項(xiàng)目模板 3.項(xiàng)目名稱 4.項(xiàng)目保存位置 點(diǎn)擊創(chuàng)建項(xiàng)目 ok,進(jìn)入編輯器了 把編輯器界面布局稍微改一下,改成2by3 點(diǎn)擊Edit 點(diǎn)擊 project settings,這是對(duì)我們所創(chuàng)建工程的設(shè)置 此外還有對(duì)

    2024年01月25日
    瀏覽(95)
  • Unity Physics2D 2d物理引擎游戲 筆記

    Unity Physics2D 2d物理引擎游戲 筆記

    2d 材質(zhì) 里面可以設(shè)置 摩擦力 和 彈力 Simulated:是否在當(dāng)前的物理環(huán)境中模擬,取消勾選該框類似于Disable Rigidbody,但使用這個(gè)參數(shù)更加高效,因?yàn)镈isable會(huì)銷毀內(nèi)部產(chǎn)生的GameObject,而取消勾選Simulated只是禁用。 Kinematic 動(dòng)力學(xué)剛體 動(dòng)力學(xué)剛體不受重力和力的影響,而受用戶的

    2023年04月24日
    瀏覽(93)
  • 用unity寫一個(gè)2D類的拼圖游戲

    用unity寫一個(gè)2D類的拼圖游戲

    前幾天接了一個(gè)拼圖項(xiàng)目剛好現(xiàn)在寫完了,拿出來(lái)分享,拼圖不難,我也是看了一個(gè)官方案例寫的,因?yàn)楫?dāng)我們寫圖片跟隨鼠標(biāo)的時(shí)候,鼠標(biāo)已經(jīng)有一個(gè)圖片了,這個(gè)圖片會(huì)遮擋射線,然后就無(wú)法判斷當(dāng)前拼圖塊在哪里,話不多說(shuō),上菜 1、新建總控腳本LevelManager 2、新建Pu

    2024年02月08日
    瀏覽(28)
  • Unity創(chuàng)建一個(gè)可移動(dòng)的2D角色

    Unity創(chuàng)建一個(gè)可移動(dòng)的2D角色

    我們首先創(chuàng)建一個(gè)角色,這里我新建了一個(gè)膠囊體用來(lái)當(dāng)Player,一個(gè)Square用來(lái)當(dāng)?shù)孛妗?接下來(lái),為角色增加碰撞體和剛體,為地面增加碰撞體。然后我們?yōu)镻layer的剛體增加一個(gè)Z軸的約束,避免其東倒西歪。如下圖所示: 同時(shí),為角色添加一個(gè)空物體作為子物體,用來(lái)向地面

    2024年02月10日
    瀏覽(23)
  • Unity2d游戲項(xiàng)目--小狐貍

    Unity2d游戲項(xiàng)目--小狐貍

    (一) 在文件夾中找到back圖片,并在檢查器面板中將back圖片的每單位像素?cái)?shù)設(shè)置為16。 (文件所在地) (面板設(shè)置) (二) 將圖片拖入到場(chǎng)景中 (一) 生成矩形的瓦片地圖 (二) 打開(kāi)平鋪調(diào)色板 (三) 新建并命名為map,在原目錄新建一個(gè)文件夾,用于存放你在這個(gè)瓦

    2024年02月03日
    瀏覽(32)
  • 【unity】制作一個(gè)角色的初始狀態(tài)(左右跳二段跳)【2D橫板動(dòng)作游戲】

    【unity】制作一個(gè)角色的初始狀態(tài)(左右跳二段跳)【2D橫板動(dòng)作游戲】

    ? ? ? ? hi~ 大家好!歡迎大家來(lái)到我的全新unity學(xué)習(xí)記錄系列?,F(xiàn)在我想在2d橫板游戲中,實(shí)現(xiàn)一個(gè)角色的初始狀態(tài)-閑置狀態(tài)、移動(dòng)狀態(tài)、空中狀態(tài)。并且是利用 狀態(tài)機(jī) 進(jìn)行實(shí)現(xiàn)的。 ? ? ? ? 本系列是跟著視頻教程走的,所寫也是作者個(gè)人的學(xué)習(xí)記錄筆記。如有錯(cuò)誤請(qǐng)聯(lián)系

    2024年02月04日
    瀏覽(21)
  • Unity 新建你的第一個(gè)游戲,以及如何按WASD控制角色運(yùn)動(dòng) (Unity Demo2D)

    Unity 新建你的第一個(gè)游戲,以及如何按WASD控制角色運(yùn)動(dòng) (Unity Demo2D)

    當(dāng)你打開(kāi) Unity Hub,初始化一個(gè) 2D 項(xiàng)目,進(jìn)入了 Unity 編輯器,你會(huì)發(fā)現(xiàn)在 左側(cè) : 一個(gè)叫 SampleScene (或者其他) 的場(chǎng)景 場(chǎng)景下有一個(gè) Main Camera,主相機(jī) 這就是一個(gè)新建的 2D 項(xiàng)目自帶的內(nèi)容。 在 Main Camera 同級(jí)目錄新建: 2D Object - Sprites - Capsule ,這里 Capsule 是精靈的種類,我們

    2024年02月02日
    瀏覽(17)
  • 【實(shí)現(xiàn)100個(gè)unity游戲之20】制作一個(gè)2d開(kāi)放世界游戲,TileMap+柏林噪聲生成隨機(jī)地圖(附源碼)

    【實(shí)現(xiàn)100個(gè)unity游戲之20】制作一個(gè)2d開(kāi)放世界游戲,TileMap+柏林噪聲生成隨機(jī)地圖(附源碼)

    我的上一篇文章介紹了TileMap的使用,主要是為我這篇做一個(gè)鋪墊,看過(guò)上一篇文章的人,應(yīng)該已經(jīng)很好的理解TileMap的使用了,這里我就不需要過(guò)多的解釋一些繁瑣而基礎(chǔ)的知識(shí)了,省去很多時(shí)間。所有沒(méi)看過(guò)上一篇文章的小伙伴我強(qiáng)烈建議先去看看:

    2024年01月20日
    瀏覽(58)
  • 【用unity實(shí)現(xiàn)100個(gè)游戲之16】Unity中程序化生成的2D地牢5(附項(xiàng)目源碼,完結(jié))

    【視頻】:https://www.youtube.com/watch?app=desktopv=-QOCX6SVFsklist=PLcRSafycjWFenI87z7uZHFv6cUG2Tzu9vindex=1 注意 :本文為學(xué)習(xí)筆記記錄,推薦支持原作者,去看原視頻自己手敲代碼理解更加深入

    2024年02月03日
    瀏覽(22)
  • 【經(jīng)典游戲】坦克大戰(zhàn) Unity2D項(xiàng)目實(shí)戰(zhàn)(保姆級(jí)教程)

    【經(jīng)典游戲】坦克大戰(zhàn) Unity2D項(xiàng)目實(shí)戰(zhàn)(保姆級(jí)教程)

    主要內(nèi)容: 1.Unity3D引擎中的基礎(chǔ)設(shè)置。 2.2D場(chǎng)景的搭建,預(yù)制體制作。 3.2D動(dòng)畫(huà)的制作。 4.圖片圖集的有關(guān)知識(shí)。 5.碰撞器,觸發(fā)器,碰撞檢測(cè)與觸發(fā)檢測(cè)。 6.2D游戲渲染的一些知識(shí)。 7.敵人AI的編寫。 8.UGUI有關(guān)內(nèi)容,場(chǎng)景切換等。 所需資源包鏈接:https://pan.baidu.com/s/199wuwM

    2024年02月06日
    瀏覽(33)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包