游戏机制
场景是沿用巡逻兵的九块区域,在对角线分别创建一个玩家,只要两个玩家相遇就都会被摧毁,同时游戏结束,其中两个玩家有各自的摄像机,各自的动作都会显示。
游戏演示
具体实现
代码部分
CameraFlow.cs
实现摄像机跟随玩家,并且随着玩家移动的功能,和单机版的一样
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraFlow : MonoBehaviour
{
public Transform follow; //跟随的物体
void Start()
{
}
void FixedUpdate()
{
if (follow)
{
Vector3 nextpos = follow.forward * -1 * 4 + follow.up * 3 + follow.position;
this.transform.position = nextpos;
this.transform.LookAt(new Vector3(follow.position.x, follow.position.y + 2, follow.position.z));
}
}
}
NewMove.cs
主要是将以前的移动的代码,单独拿出来,放在玩家上,做成一个预制体
分别是鼠标左键,第一种攻击方式,鼠标右键,第二种攻击方式,空格键,跳跃。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class NewMove : NetworkBehaviour
{
publ