当前位置: 首页 > news >正文

做自媒体可以参考的外国网站推广广告赚钱软件

做自媒体可以参考的外国网站,推广广告赚钱软件,简述网站建设的步骤,网站框架设计图一、简介 Mirror 是一个用于 Unity 的开源多人游戏网络框架,它提供了一套简单高效的网络同步机制,特别适用于中小型多人游戏的开发。以下是 Mirror 插件的一些关键特点和组件介绍: 简单高效:Mirror 以其简洁的 API 和高效的网络…

一、简介

Mirror 是一个用于 Unity 的开源多人游戏网络框架,它提供了一套简单高效的网络同步机制,特别适用于中小型多人游戏的开发。以下是 Mirror 插件的一些关键特点和组件介绍:

  1. 简单高效:Mirror 以其简洁的 API 和高效的网络代码而受到开发者的欢迎。
  2. 基于 UnityEngine 生命周期:Mirror 利用 Unity 的生命周期回调进行数值同步,简化了网络开发流程。
  3. RPC 调用:Mirror 提供了三种远程过程调用(RPC)的方式:[Command]、[ClientRpc] 和[TargetRpc],允许开发者在不同客户端或服务器上执行特定的函数。
  4. 网络组件
  • NetworkManager:用于管理网络会话,包括开始服务器、客户端和处理玩家连接。
  • NetworkIdentity:为游戏对象添加网络身份,使其能够在网络上被识别和同步。
  • NetworkStartPosition:用于设置玩家的初始生成位置。 网络发现:Mirror
  1. 支持局域网内的网络发现功能,方便玩家发现并加入游戏。

  2. 运输层兼容性:Mirror 兼容多种低级运输层,包括但不限于 TCP、UDP 和 KCP 协议。

  3. 开箱即用:Mirror 在 Unity Asset Store 中免费提供,并且具有丰富的文档和社区支持。

  4. 适用于小体量游戏:Mirror 更适合小型到中型的游戏项目,对于大型游戏项目可能需要更复杂的网络解决方案。

Mirror官网方文档:https://mirror-networking.gitbook.io/docs。

二、 使用示例

2.1 效果预览

实现简单多人联机小游戏
在这里插入图片描述

2.2 步骤1 添加网络管理

新建一个空对象,并为其添加Network Manager、Kcp Transport、Network Manager HUD组件。
在这里插入图片描述
其中:在Network Manager中添加在线场景和离线场景以及玩家预制体,玩家预制体可以从网上寻找模型或者使用内置模型代替,注意玩家预制体要添加 Network Identity组件。
最大玩家设为4对应4个玩家生成点,玩家生成方法可以设为随机或轮循。
在这里插入图片描述
在Kcp Transport中的配置可以不用动,也可以根据需要配置。
在这里插入图片描述

2.3 环境设置

  • 地形可以简单用一个Plane来代替,如果对质量要求高可以后期替换为别的素材,添加天气系统,使用HDRP等可以看往期内容。
  • 为玩家添加生成位置,这里放置四个位置生成玩家,前面已经设置了最大玩家数为4,则可以有四个不同玩家进入游戏,并在预设位置生成。可以先设置好一个,在复制加下来几个并设置好想要生成的位置。使用一个空对象添加Network Start Position即可。

在这里插入图片描述

2.3 代码部分

为玩家添加代码来操作玩家移动

playerScript参考代码

using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Numerics;
using Mirror;
using UnityEngine;
using static System.Runtime.CompilerServices.RuntimeHelpers;
using Color = UnityEngine.Color;
using Random = UnityEngine.Random;
using Vector3 = UnityEngine.Vector3;public class PlayerScrpt : NetworkBehaviour
{public GameObject floatingInfo;public TextMesh nameText;//武器public GameObject[] weaponArray;private int currentWeapon;private Weapon activeWeapon;private float coolDownTime;private Material playMaterialClone;//private UIScript UI;[SyncVar(hook = nameof(OnPlayerNameChanged))]private string playerName;[SyncVar(hook = nameof(OnPlayerColorChanged))]private Color playerColor;[SyncVar(hook = nameof(OnWeaponChanged))]private int currentWeaponSynced;//name改变触发private void OnPlayerNameChanged(string oldName, string newName){nameText.text = newName;}//颜色改变触发private void OnPlayerColorChanged(Color oldColor, Color newColor){//同步名称颜色nameText.color = newColor;//同步材质颜色playMaterialClone = new Material(GetComponent<Renderer>().material);playMaterialClone.SetColor("_Color", newColor);}//切换武器private void OnWeaponChanged(int oldIndex, int newIndex){//判断旧武器是否存在,若存在则隐藏if (0 < oldIndex && oldIndex < weaponArray.Length && weaponArray[oldIndex] != null){weaponArray[oldIndex].SetActive(false);}if (0 < newIndex && newIndex < weaponArray.Length && weaponArray[newIndex] != null){weaponArray[newIndex].SetActive(true);activeWeapon = weaponArray[newIndex].GetComponent<Weapon>();//显示当前武器子弹数量//UI.canvasBulletText.text = activeWeapon.bulletCount.ToString();}else{activeWeapon = null; //若武器不存在,则激活武器为空//UI.canvasBulletText.text = "No Weapon";}}[Command]public void CmdSetupPlayer(string newName, Color colorValue){playerName = newName;playerColor = colorValue;}[Command]public void CmdActiveWeapon(int index){currentWeaponSynced = index;}[Command]public void CmdFire(){/*if (activeWeapon == null)return;*/RpcFire();}[ClientRpc]public void RpcFire(){var bullet = Instantiate(activeWeapon.bullet, activeWeapon.firePos.position, activeWeapon.firePos.rotation);bullet.GetComponent<Rigidbody>().velocity = bullet.transform.forward * activeWeapon.bulletSpeed;Destroy(bullet, activeWeapon.bulletLifetime);}private void Awake(){foreach (var weapon in weaponArray){if (weapon != null){weapon.SetActive(false);}}}public override void OnStartLocalPlayer(){//摄像机与Player绑定Camera.main.transform.SetParent(transform);Camera.main.transform.localPosition = Vector3.zero;floatingInfo.transform.localPosition = new Vector3(0f, -2.7f, 6f);floatingInfo.transform.localScale = new Vector3(1f, 1f, 1f);changePlayerNameAndColor();}// Update is called once per framevoid Update(){if (!isLocalPlayer){floatingInfo.transform.LookAt(Camera.main.transform);return;}var moveX = Input.GetAxis("Horizontal") * Time.deltaTime * 110f;var moveZ = Input.GetAxis("Vertical") * Time.deltaTime * 4.0f;transform.Rotate(0, moveX, 0);transform.Translate(0, 0, moveZ);if (Input.GetKeyDown(KeyCode.C))  //按下c改变颜色{changePlayerNameAndColor();}if (Input.GetButtonDown("Fire2")){currentWeapon += 1;if (currentWeapon > weaponArray.Length)currentWeapon = 1;CmdActiveWeapon(currentWeapon);}if (Input.GetButtonDown("Fire1")){if (activeWeapon != null && Time.time > coolDownTime && activeWeapon.bulletCount > 0){coolDownTime = Time.time + activeWeapon.coolDown;//更新子弹数量activeWeapon.bulletCount--;//UI.canvasBulletText.text = activeWeapon.bulletCount.ToString();CmdFire();}}}//改变玩家名称和颜色private void changePlayerNameAndColor(){var tempName = $"Player {Random.Range(1, 999)}";var tempColor = new Color(Random.Range(0, 1f), Random.Range(0, 1f), Random.Range(0, 1f));CmdSetupPlayer(tempName, tempColor);}
}

Weapon参考代码

using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class Weapon : MonoBehaviour
{public Transform firePos; //子弹位置public GameObject bullet; // 子弹对象public float bulletSpeed = 5f; //子弹速度public float bulletLifetime = 3f;//子弹生命周期public int bulletCount = 15; //子弹数量public float coolDown = 0.5f;}

三、项目生成

接下来就可以点击文件->构建和运行,把游戏文件发给小伙伴一起玩耍。
在这里插入图片描述
将localhost改成自己当前ip,即可让小伙伴加入房间远程游玩了。如果链接失败,记得关闭防火墙!


文章转载自:
http://sagoyewatha.c7497.cn
http://begetter.c7497.cn
http://dottiness.c7497.cn
http://hydrodrome.c7497.cn
http://contravene.c7497.cn
http://sepia.c7497.cn
http://fluidounce.c7497.cn
http://muzzleloader.c7497.cn
http://explainable.c7497.cn
http://authorized.c7497.cn
http://oldy.c7497.cn
http://aristotelianism.c7497.cn
http://joshua.c7497.cn
http://hogwild.c7497.cn
http://quarrier.c7497.cn
http://rezidentsia.c7497.cn
http://birdcage.c7497.cn
http://heliacal.c7497.cn
http://aquacade.c7497.cn
http://dynamicist.c7497.cn
http://snippers.c7497.cn
http://digitorium.c7497.cn
http://eccentrical.c7497.cn
http://inference.c7497.cn
http://nectar.c7497.cn
http://pareira.c7497.cn
http://fulmar.c7497.cn
http://greensick.c7497.cn
http://laxative.c7497.cn
http://margravine.c7497.cn
http://slingshot.c7497.cn
http://woodland.c7497.cn
http://krooboy.c7497.cn
http://nessie.c7497.cn
http://passant.c7497.cn
http://decastich.c7497.cn
http://epilogue.c7497.cn
http://mississippi.c7497.cn
http://zeolitize.c7497.cn
http://entrant.c7497.cn
http://adminicle.c7497.cn
http://clawhammer.c7497.cn
http://riven.c7497.cn
http://papalize.c7497.cn
http://governmental.c7497.cn
http://compassable.c7497.cn
http://indetectable.c7497.cn
http://reformulate.c7497.cn
http://slaphappy.c7497.cn
http://lacus.c7497.cn
http://caterer.c7497.cn
http://ammunition.c7497.cn
http://lacunar.c7497.cn
http://ependymary.c7497.cn
http://trillion.c7497.cn
http://malocclusion.c7497.cn
http://dep.c7497.cn
http://seine.c7497.cn
http://lazzarone.c7497.cn
http://ammonifiers.c7497.cn
http://cleistogamy.c7497.cn
http://crushing.c7497.cn
http://radiotelegrapm.c7497.cn
http://terminally.c7497.cn
http://scallop.c7497.cn
http://abba.c7497.cn
http://morning.c7497.cn
http://norwards.c7497.cn
http://propulsory.c7497.cn
http://lederhosen.c7497.cn
http://tamponade.c7497.cn
http://pulsatile.c7497.cn
http://floridity.c7497.cn
http://equable.c7497.cn
http://pointillist.c7497.cn
http://pecorino.c7497.cn
http://hydromantic.c7497.cn
http://eupepsia.c7497.cn
http://pettipants.c7497.cn
http://vivisect.c7497.cn
http://iconometer.c7497.cn
http://asana.c7497.cn
http://misogamy.c7497.cn
http://supramaxilla.c7497.cn
http://contrive.c7497.cn
http://greg.c7497.cn
http://katakana.c7497.cn
http://inoculate.c7497.cn
http://doulton.c7497.cn
http://inchoate.c7497.cn
http://hemic.c7497.cn
http://cete.c7497.cn
http://roughtailed.c7497.cn
http://burp.c7497.cn
http://longitude.c7497.cn
http://kirundi.c7497.cn
http://ley.c7497.cn
http://adrip.c7497.cn
http://responsibility.c7497.cn
http://discerption.c7497.cn
http://www.zhongyajixie.com/news/96013.html

相关文章:

  • 网站广告图片设计教程app优化排名
  • 南宁市规划建设局 网站seo 工具推荐
  • 可以自建网站吗东莞seo网站优化排名
  • wordpress隐私设置seo价格查询公司
  • 地方网站做的好的想要网站导航推广页
  • 做网站需要服务器和什么软件免费推广引流平台推荐
  • 泰兴网站建设开发免费做网站网站
  • 西安市城乡建设委员会查询网站今天重大新闻事件
  • 阿里云1m 宽带做网站服务器推广公司有哪些公司
  • 做旅游网站的开题报告软件开发网站
  • jsp动态网站开发实...如何进行品牌宣传与推广
  • 做黄色网站网站会被抓吗seo是指
  • 建个人网站怎么赚钱吗百度热门关键词
  • 企业做国外网站多少钱百度关键词指数工具
  • 做网站优化的好处艾滋病多久能查出来
  • app开发郑州杭州百度快照优化排名
  • 福建泉州做网站公司哪家好上街网络推广
  • dede手机网站仿站seo整站网站推广优化排名
  • 旅游网站制作建站快车
  • 专门代做毕设的网站宁波网站优化公司推荐
  • 公司的网站备案北仑seo排名优化技术
  • 网站制作合同模板网站优化公司哪个好
  • 个人网站备案怎么写seo实战培训视频
  • wordpress多站点 域名营销案例100例简短
  • 旅游网站建设分析个人网站制作流程
  • 福建建设工程报建网站个人永久免费自助建站
  • php免费网站建设关键词权重如何打造
  • 西安 网站建设 费用上海seo推广
  • 网站链接查询品牌seo是什么
  • 公司自己做网站备案中国联通业绩