0
こんにちは、私はRTSゲームに取り組んでいますので、私は1人のミニオンをコントロールしますが、もう1人のミニオンを追加してポイントに行くように命令してから、http://imgur.com/a/uHwjGのように見ます。 手先が移動するためのコードはこれです:Unity複数のnavmeshエージェント。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class moveTest : MonoBehaviour {
NavMeshAgent navAgent;
// Use this for initialization
void Start() {
navAgent = GetComponent<NavMeshAgent>();
}
// Update is called once per frame
void Update() {
move();
}
void move()
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Input.GetMouseButtonDown(1))
{
if (Physics.Raycast(ray, out hit, 1000))
{
navAgent.SetDestination(hit.point);
}
}
}
}
例のように説明できますか –