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

Unity進(jìn)階–通過(guò)PhotonServer實(shí)現(xiàn)人物選擇和多人同步–PhotonServer(四)

這篇具有很好參考價(jià)值的文章主要介紹了Unity進(jìn)階–通過(guò)PhotonServer實(shí)現(xiàn)人物選擇和多人同步–PhotonServer(四)。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

Unity進(jìn)階–通過(guò)PhotonServer實(shí)現(xiàn)人物選擇和多人同步–PhotonServer(四)

服務(wù)端

  • 服務(wù)端結(jié)構(gòu)如下:

    Unity進(jìn)階–通過(guò)PhotonServer實(shí)現(xiàn)人物選擇和多人同步–PhotonServer(四),unity游戲開(kāi)發(fā),unity,java,游戲引擎

  • UserModel

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace PhotonServerFirst.Model.User
    {
        public class UserModel
        {
            public int ID;
            public int Hp;
            public float[] Points = new float[] { -4, 1, -2 }; 
            public UserInfo userInfo;
        }
    
        public class UserInfo
        {
            public static UserInfo[] userList = new UserInfo[] {
                new UserInfo(){ ModelID = 0, MaxHp = 100, Attack = 20, Speed = 3 },
                new UserInfo(){ ModelID = 1, MaxHp = 70, Attack = 40, Speed = 4 }
            };
            public int ModelID;
            public int MaxHp;
            public int Attack;
            public int Speed;
        } 
    }
    
    
    • Messaage

      namespace Net
      {
          public class Message
          {
              public byte Type;
              public int Command;
              public object Content;
              public Message() { }
      
              public Message(byte type, int command, object content)
              {
                  Type = type;
                  Command = command;
                  Content = content;
              }
          }
          //消息類(lèi)型
          public class MessageType
          {
              //unity
              //類(lèi)型
              public static byte Type_Audio = 1;
              public static byte Type_UI = 2;
              public static byte Type_Player = 3;
              //聲音命令
              public static int Audio_PlaySound = 100;
              public static int Audio_StopSound = 101;
              public static int Audio_PlayMusic = 102;
              //UI命令
              public static int UI_ShowPanel = 200;
              public static int UI_AddScore = 201;
              public static int UI_ShowShop = 202;
      
              //網(wǎng)絡(luò)
              public const byte Type_Account = 1;
              public const byte Type_User = 2;
              //注冊(cè)賬號(hào)
              public const int Account_Register = 100;
              public const int Account_Register_Res = 101;
              //登陸
              public const int Account_Login = 102;
              public const int Account_Login_res = 103;
      
              //選擇角色
              public const int User_Select = 104; 
              public const int User_Select_res = 105; 
              public const int User_Create_Event = 106;
      
              //刪除角色
              public const int User_Remove_Event = 107;
          }
      }
      
      
    • PSPeer

      using System;
      using System.Collections.Generic;
      using Net;
      using Photon.SocketServer;
      using PhotonHostRuntimeInterfaces;
      using PhotonServerFirst.Bll;
      
      namespace PhotonServerFirst
      {
          public class PSPeer : ClientPeer
          {
              public PSPeer(InitRequest initRequest) : base(initRequest)
              {
      
              }
      
              //處理客戶端斷開(kāi)的后續(xù)工作
              protected override void OnDisconnect(DisconnectReason reasonCode, string reasonDetail)
              {
                  //關(guān)閉管理器
                  BLLManager.Instance.accountBLL.OnDisconnect(this);
                  BLLManager.Instance.userBLL.OnDisconnect(this);
              }
      
              //處理客戶端的請(qǐng)求
              protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
              {
                  PSTest.log.Info("收到客戶端的消息");
                  var dic = operationRequest.Parameters;
      
                  //打包,轉(zhuǎn)為PhotonMessage
                  Message message = new Message();
                  message.Type = (byte)dic[0];
                  message.Command = (int)dic[1];
                  List<object> objs = new List<object>();
                  for (byte i = 2; i < dic.Count; i++)
                  {
                      objs.Add(dic[i]);
                  }
                  message.Content = objs.ToArray();
      
                  //消息分發(fā)
                  switch (message.Type)
                  {
                      case MessageType.Type_Account:
                          BLLManager.Instance.accountBLL.OnOperationRequest(this, message); 
                          break;
                      case MessageType.Type_User:
                          BLLManager.Instance.userBLL.OnOperationRequest(this, message);
                          break;
                  }
              }
          }
      }
      
      
      • UserBLL

        using Net;
        using PhotonServerFirst.Model.User;
        using PhotonServerFirst.Dal;
        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Text;
        
        namespace PhotonServerFirst.Bll.User
        {
            class UserBLL : IMessageHandler
            {
                public void OnDisconnect(PSPeer peer)
                {
                    //下線
                    UserModel user = DALManager.Instance.userDAL.GetUserModel(peer);
                    //移除角色
                    DALManager.Instance.userDAL.RemoveUser(peer);
                    //通知其他角色該角色已經(jīng)下線
                    foreach (PSPeer otherpeer in DALManager.Instance.userDAL.GetuserPeers())
                    {
                        SendMessage.Send(otherpeer, MessageType.Type_User, MessageType.User_Remove_Event, user.ID);
                    }
        
                }
        
                    public void OnOperationRequest(PSPeer peer, Message message)
                {
                    switch (message.Command)
                    {
                        case MessageType.User_Select:
                            //有人選了角色
                            //創(chuàng)建其他角色
                            CreateOtherUser(peer, message);
                            //創(chuàng)建自己的角色
                            CreateUser(peer, message);
                            //通知其他角色創(chuàng)建自己
                            CreateUserByOthers(peer, message); 
                            break;
                    }
                }
        
                    //創(chuàng)建目前已經(jīng)存在的角色
                    void CreateOtherUser(PSPeer peer, Message message)
                    {
                        //遍歷已經(jīng)登陸的角色
                        foreach (UserModel userModel in DALManager.Instance.userDAL.GetUserModels())
                        {
                            //給登錄的客戶端響應(yīng),讓其創(chuàng)建這些角色 角色id 模型id 位置
                            SendMessage.Send(peer, MessageType.Type_User, MessageType.User_Create_Event, userModel.ID, userModel.userInfo.ModelID, userModel.Points);
                        }
                    }
        
                    //創(chuàng)建自己角色
                    void CreateUser(PSPeer peer, Message message)
                    {
                        object[] obj = (object[])message.Content;
                        //客戶端傳來(lái)模型id
                        int modelId = (int)obj[0];
                        //創(chuàng)建角色
                        int userId = DALManager.Instance.userDAL.AddUser(peer, modelId);
                        //告訴客戶端創(chuàng)建自己的角色
                        SendMessage.Send(peer, MessageType.Type_User, MessageType.User_Select_res, userId, modelId, DALManager.Instance.userDAL.GetUserModel(peer).Points);
                    }
        
                    //通知其他角色創(chuàng)建自己
                    void CreateUserByOthers(PSPeer peer, Message message)
                    {
                        UserModel userModel = DALManager.Instance.userDAL.GetUserModel(peer);
                        //遍歷全部客戶端,發(fā)送消息
                        foreach (PSPeer otherpeer in DALManager.Instance.userDAL.GetuserPeers())
                        {
                            if (otherpeer == peer)
                            {
                                continue;
                            }
                            SendMessage.Send(otherpeer, MessageType.Type_User, MessageType.User_Create_Event, userModel.ID, userModel.userInfo.ModelID, userModel.Points);
                        }
                }
            }   
         }
        
        
      • BLLManager

        using PhotonServerFirst.Bll.User;
        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Text;
        
        namespace PhotonServerFirst.Bll
        {
            public class BLLManager
            {
                private static BLLManager bLLManager;
                public static BLLManager Instance
                {
                    get
                    {
                        if(bLLManager == null)
                        {
                            bLLManager = new BLLManager();
                        }
                        return bLLManager;
                    }
                }
                //登錄注冊(cè)管理
                public IMessageHandler accountBLL;
                //角色管理
                public IMessageHandler userBLL;
        
                private BLLManager()
                {
                    accountBLL = new PhsotonServerFirst.Bll.Account.AccountBLL();
                    userBLL = new UserBLL();
                }
        
            }
        }
        
        
        • UserDAL

          using System;
          using System.Collections.Generic;
          using System.Linq;
          using System.Text;
          using PhotonServerFirst.Model.User;
          
          namespace PhotonServerFirst.Dal.User
          {
              class UserDAL
              {
                  //角色保存集合
                  private Dictionary<PSPeer, UserModel> peerUserDic = new Dictionary<PSPeer, UserModel>();
                  private int userId = 1;
          
                  /// <summary>
                  ///添加一名角色
                  /// </summary>
                  /// <param name="peer">連接對(duì)象</param>
                  /// <param name="index">幾號(hào)角色</param>
                  /// <returns>用戶id</returns>
                  public int AddUser(PSPeer peer, int index)
                  {
                      UserModel model = new UserModel();
                      model.ID = userId++;
                      model.userInfo = UserInfo.userList[index];
                      model.Hp = model.userInfo.MaxHp;
                      if (index == 1)
                      {
                          model.Points = new float[] { 0, 2, -2 };
                      }
                      peerUserDic.Add(peer, model);
                      return model.ID;
                  }
          
                  ///<summary>
                  ///移除一名角色
                  /// </summary>
                  public void RemoveUser(PSPeer peer)
                  {
                      peerUserDic.Remove(peer);
                  }
          
          
                  ///<summary>
                  ///得到用戶模型
                  ///</summary>
                  ///<param name="peer">連接對(duì)象</param>
                  ///<returns>用戶模型</returns>
                  public UserModel GetUserModel(PSPeer peer){
                       return peerUserDic[peer];
                  }
          
                  ///<summary>
                  ///得到全部的用戶模型
                  ///</summary>
                  public UserModel[] GetUserModels() {
                      return peerUserDic.Values.ToArray();
                  }
          
                  ///<summary>
                  ///得到全部有角色的連接對(duì)象
                  ///</summary>
                  public PSPeer[] GetuserPeers()
                  {
                      return peerUserDic.Keys.ToArray();
                  }
          
              }
          }
          
          
        • DALManager

          using PhotonServerFirst.Bll;
          using PhotonServerFirst.Dal.User;
          using System;
          using System.Collections.Generic;
          using System.Linq;
          using System.Text;
          
          namespace PhotonServerFirst.Dal
          {
              class DALManager
              {
                  private static DALManager dALManager;
                  public static DALManager Instance
                  {
                      get
                      {
                          if (dALManager == null)
                          {
                              dALManager = new DALManager();
                          }
                          return dALManager;
                      }
                  }
                  //登錄注冊(cè)管理
                  public AccountDAL accountDAL;
                  //用戶管理
                  public UserDAL userDAL;
          
                  private DALManager()
                  {
                      accountDAL = new AccountDAL();
                      userDAL = new UserDAL();
                  }
              }
          }
          
          

客戶端

  • 客戶端頁(yè)面

Unity進(jìn)階–通過(guò)PhotonServer實(shí)現(xiàn)人物選擇和多人同步–PhotonServer(四),unity游戲開(kāi)發(fā),unity,java,游戲引擎

  • 綁在panel上

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using Net;
    
    public class SelectPanel : MonoBehaviour
    {
        // Start is called before the first frame update
        void Start()
        {
            
        }
    
        // Update is called once per frame
        void Update()
        {
            
        }
    
        public void SelectHero(int modelId){
            //告訴服務(wù)器創(chuàng)建角色
            PhotonManager.Instance.Send(MessageType.Type_User, MessageType.User_Select, modelId);
            //摧毀選擇角色頁(yè)面
            Destroy(gameObject);
            //顯示計(jì)分版
            UImanager.Instance.SetActive("score", true);
        }
    
    }
    
    
  • 后臺(tái)持續(xù)運(yùn)行

    Unity進(jìn)階–通過(guò)PhotonServer實(shí)現(xiàn)人物選擇和多人同步–PhotonServer(四),unity游戲開(kāi)發(fā),unity,java,游戲引擎

    • 建一個(gè)usermanager,綁定以下腳本

      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      using Net;
      
      public class UserManager : ManagerBase 
      {
          void Start(){
              MessageCenter.Instance.Register(this);
          }
      
          public override void ReceiveMessage(Message message){
              base.ReceiveMessage(message);
              //打包
              object[] obs = (object[])message.Content;
              //消息分發(fā)
              switch(message.Command){
                  case MessageType.User_Select_res:
                  selectUser(obs);
                  break;
                  case MessageType.User_Create_Event:
                  CreateotherUser(obs);
                  break;
                  case MessageType.User_Remove_Event:
                  RemoveUser(obs);
                  break;
              }
          }  
      
          public override byte GetMessageType(){
              return MessageType.Type_User;
          }
      
          //選擇了自己的角色
          void selectUser(object[] objs){
              int userId =(int)objs[0];
              int modelId = (int)objs[1];
              float[] point = (float[])objs[2];
              if (userId > 0)
              {
                  //創(chuàng)建角色
                  GameObject UserPre = Resources.Load<GameObject>("User/" + modelId);
                  UserControll user = Instantiate(UserPre,new Vector3(point[0],point[1],point[2]),Quaternion.identity).GetComponent<UserControll>();
      
                  UserControll.ID =userId;
                  //保存到集合中
                  UserControll.idUserDic.Add(userId, user);
              }
              else {
                  Debug.Log("創(chuàng)建角色失敗");
              }
          }
      
          //創(chuàng)建其他角色
          void CreateotherUser(object[] objs){
              //打包
              int userId = (int)objs[0];
              int modelId = (int)objs [1];
              float[] point = (float[])objs[2];
              GameObject UserPre = Resources.Load<GameObject>("User/" + modelId);
              UserControll user = Instantiate(UserPre, new Vector3(point[0],point[1], point[2]),Quaternion.identity).GetComponent<UserControll>();
              UserControll.idUserDic.Add(userId, user);
          }
      
          //刪除一名角色
          void RemoveUser(object[] objs){
              int userId = (int)objs[0];
              UserControll user = UserControll.idUserDic[userId];
              UserControll.idUserDic.Remove(userId);
              Destroy(user.gameObject);
          }
      
      
      }
      
      
    • 給物體上綁定

      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      
      public class UserControll : MonoBehaviour
      {
          //保存了所有角色的集合
          public static Dictionary<int, UserControll> idUserDic = new Dictionary<int, UserControll>();
          //當(dāng)前客戶端角色的id
          public static int ID;
          private Animator ani;
      
          // Start is called before the first frame update
          void Start()
          {
              ani = GetComponent<Animator>();
          }
      
          // Update is called once per frame
          void Update()
          {
              
          }
      }
      
      
    • 別忘了按鈕綁定

      Unity進(jìn)階–通過(guò)PhotonServer實(shí)現(xiàn)人物選擇和多人同步–PhotonServer(四),unity游戲開(kāi)發(fā),unity,java,游戲引擎文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-660612.html

到了這里,關(guān)于Unity進(jìn)階–通過(guò)PhotonServer實(shí)現(xiàn)人物選擇和多人同步–PhotonServer(四)的文章就介紹完了。如果您還想了解更多內(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】實(shí)用功能開(kāi)發(fā)(一)實(shí)現(xiàn)在UI中用RawImage實(shí)時(shí)展示3D模型(背景透明,并通過(guò)UI防止3D場(chǎng)景遮擋)并可以通過(guò)分層完成:游戲中的人物狀態(tài)展示界面,小地圖,人物實(shí)時(shí)頭像狀態(tài)等功能

    【Unity】實(shí)用功能開(kāi)發(fā)(一)實(shí)現(xiàn)在UI中用RawImage實(shí)時(shí)展示3D模型(背景透明,并通過(guò)UI防止3D場(chǎng)景遮擋)并可以通過(guò)分層完成:游戲中的人物狀態(tài)展示界面,小地圖,人物實(shí)時(shí)頭像狀態(tài)等功能

    有時(shí)由于項(xiàng)目效果需要,部分功能的實(shí)現(xiàn)受到阻礙,這里收集一些已實(shí)現(xiàn)的思路和方法,每次會(huì)記錄大致需求和遇到的問(wèn)題,如果有更好的想法,歡迎評(píng)論區(qū)討論?。?! 目錄 功能描述: 需求描述: 實(shí)現(xiàn)步驟: ①為需要展示的內(nèi)容區(qū)分層級(jí): ②在場(chǎng)景中添加一個(gè)攝像機(jī),并

    2024年02月04日
    瀏覽(35)
  • Unity 通過(guò)鼠標(biāo)控制模擬人物移動(dòng)和旋轉(zhuǎn)視角

    Unity 通過(guò)鼠標(biāo)控制模擬人物移動(dòng)和旋轉(zhuǎn)視角

    要通過(guò)鼠標(biāo)控制并模擬人物移動(dòng)和轉(zhuǎn)換視角,將會(huì)使用射線檢測(cè)、鼠標(biāo)點(diǎn)擊和鼠標(biāo)水平移動(dòng),配合物體旋轉(zhuǎn)和移動(dòng)方法共同實(shí)現(xiàn)。 首先搭建個(gè)由一個(gè)Plane地板和若干cube組成的簡(jiǎn)單場(chǎng)景: 其次創(chuàng)建一個(gè)Capsule作為移動(dòng)物體,并把攝像頭拉到該物體中。 創(chuàng)建以下腳本: ?把腳本拉

    2024年02月03日
    瀏覽(17)
  • Unity多人聯(lián)機(jī)的實(shí)現(xiàn)

    實(shí)現(xiàn)多人聯(lián)機(jī)的方法有幾種,具體取決于你的具體需求。以下是一些選項(xiàng): Unity Multiplayer:Unity有自己的內(nèi)置網(wǎng)絡(luò)解決方案,稱(chēng)為Unity Multiplayer(以前稱(chēng)為UNET)。這允許您創(chuàng)建可以在互聯(lián)網(wǎng)或本地網(wǎng)絡(luò)上玩的多人游戲。您可以在官方Unity文檔中找到有關(guān)Unity Multiplayer的更多信息

    2024年02月11日
    瀏覽(23)
  • git通過(guò)fork-merge request實(shí)現(xiàn)多人協(xié)同

    git通過(guò)fork-merge request實(shí)現(xiàn)多人協(xié)同

    對(duì)于一個(gè)項(xiàng)目,如果需要多人協(xié)同開(kāi)發(fā),大家都在原始倉(cāng)庫(kù)中進(jìn)行修改提交,經(jīng)常會(huì)發(fā)生沖突,而且一不小心會(huì)把別人的代碼內(nèi)容覆蓋掉。為了避免這樣的問(wèn)題,git提供了fork-merge request這樣的協(xié)同方式。 首先git倉(cāng)庫(kù)分為遠(yuǎn)端倉(cāng)庫(kù)和本地倉(cāng)庫(kù)分別對(duì)應(yīng)上圖的remote和local。 sourc

    2024年02月11日
    瀏覽(19)
  • Unity實(shí)現(xiàn)人物旋轉(zhuǎn)+移動(dòng)

    思路:首先要有個(gè)變量去記錄下操作前的一個(gè)方向狀態(tài)。(本次操作的對(duì)象是正面對(duì)著屏幕的。)然后還有有個(gè)變量去描述將要發(fā)生的方向。接著要明確,前和后,左和右是橫跨180°的,其他的兩兩是相差90°的。所以我們可以以90°一個(gè)單位去做旋轉(zhuǎn)。并且利用前面總結(jié)的方向

    2024年02月14日
    瀏覽(21)
  • Unity實(shí)現(xiàn)人物移動(dòng)、旋轉(zhuǎn)、跳躍

    Unity實(shí)現(xiàn)人物移動(dòng)、旋轉(zhuǎn)、跳躍

    1.Player腳本控制人物移動(dòng),可單獨(dú)使用。(人物需添加組件 Box ? Collider和Rigidbody ) 2.相機(jī)放在人物頭部,轉(zhuǎn)動(dòng)需要帶著人物轉(zhuǎn),相機(jī)轉(zhuǎn)動(dòng)靈敏度和上下轉(zhuǎn)動(dòng)角度范圍根據(jù)具體情況配置。 腳本CameraController和Player直接掛載到人物就可以用了。 3. 文件目錄(人物final bowser fly,相

    2024年02月04日
    瀏覽(22)
  • unity使用PhotonEngine實(shí)現(xiàn)多人聯(lián)機(jī)游戲開(kāi)發(fā)(一)

    unity使用PhotonEngine實(shí)現(xiàn)多人聯(lián)機(jī)游戲開(kāi)發(fā)(一)

    先來(lái)了解一下PhotonEngine(光子引擎),這是德國(guó)ExitGame公司開(kāi)發(fā)的網(wǎng)絡(luò)引擎,photonengine簡(jiǎn)單易上手,很多游戲公司開(kāi)發(fā)的網(wǎng)絡(luò)游戲都是使用的這個(gè)。這個(gè)網(wǎng)絡(luò)引擎里面包括了PhotonCloud(光子云)、photonServer(光子服務(wù)器)、PhotonQuantum(確定性量子引擎)、PhotonVoice(光子語(yǔ)音)

    2024年02月07日
    瀏覽(29)
  • 〔011〕Stable Diffusion 之 解決繪制多人或面部很小的人物時(shí)面部崩壞問(wèn)題 篇

    〔011〕Stable Diffusion 之 解決繪制多人或面部很小的人物時(shí)面部崩壞問(wèn)題 篇

    相信很多人在畫(huà)圖時(shí)候,特別是畫(huà) 有多個(gè)人物 圖片或者 人物在圖片中很小 的時(shí)候,都會(huì)很容易出現(xiàn)面部崩壞的問(wèn)題 這是由于神經(jīng)網(wǎng)絡(luò)無(wú)法完全捕捉人臉的微妙細(xì)節(jié)和變化,導(dǎo)致產(chǎn)生了不自然或扭曲的結(jié)果 雖然 stable diffusion 在出圖的時(shí)候自帶了一個(gè) 面部修復(fù)(Restore faces) 按

    2024年02月12日
    瀏覽(20)
  • Unity mirror實(shí)現(xiàn)多人同時(shí)在線(LINUX)保姆級(jí)

    Unity mirror實(shí)現(xiàn)多人同時(shí)在線(LINUX)保姆級(jí)

    話不多說(shuō)直接開(kāi)始 1?申請(qǐng)服務(wù)器(阿里云/騰訊云) 筆者這邊直接白嫖的阿里云一個(gè)月,測(cè)試學(xué)習(xí)一個(gè)月應(yīng)該是夠了。記得重置密碼并記錄 申請(qǐng)完成后點(diǎn)擊左側(cè)目錄找到云服務(wù)器。記住這個(gè)公有服務(wù)器,等等會(huì)用到。 2 Unity Mirror?坦克大戰(zhàn)場(chǎng)景 在NetworkManager找到對(duì)應(yīng)地址,填寫(xiě)

    2024年02月06日
    瀏覽(32)
  • 實(shí)現(xiàn)3D人物的移動(dòng)和旋轉(zhuǎn)。(Unity)

    實(shí)現(xiàn)3D人物的移動(dòng)和旋轉(zhuǎn)。(Unity)

    首先,需要在人物身上加剛體和碰撞器。 ? 如果需要人物身上有聲音,可以添加AudioSource音頻源。 ?然后創(chuàng)建腳本,需要把腳本掛載到對(duì)應(yīng)的對(duì)象身上。 如果有動(dòng)畫(huà),還需要?jiǎng)?chuàng)建狀態(tài)機(jī)添加到對(duì)應(yīng)的對(duì)象上面,并且設(shè)置好里面的動(dòng)畫(huà)。 ?代碼實(shí)現(xiàn): 圖片實(shí)現(xiàn): ? ? 上面代碼

    2024年02月04日
    瀏覽(22)

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

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

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

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

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包