A* Pathfinding Project  4.1.5
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
ManualRVOAgent.cs

Player controlled character which RVO agents will avoid.This script is intended to show how you can make NPCs avoid a player controlled (or otherwise externally controlled) character.

See Also
Pathfinding.RVO.RVOController
Pathfinding.Examples.ManualRVOAgent
//@AstarPro
using UnityEngine;
using System.Collections;
namespace Pathfinding.Examples {
using Pathfinding.RVO;
[RequireComponent(typeof(RVOController))]
public class ManualRVOAgent : MonoBehaviour {
RVOController rvo;
public float speed = 1;
void Awake () {
rvo = GetComponent<RVOController>();
}
void Update () {
var x = Input.GetAxis("Horizontal");
var y = Input.GetAxis("Vertical");
var v = new Vector3(x, 0, y) * speed;
// Override the RVOController's velocity. This will disable local avoidance calculations for one simulation step.
rvo.velocity = v;
transform.position += v * Time.deltaTime;
}
}
}