Hello and God bless you,
As the title says, my character starts to turn around in a circular movement forever if the speed of my character is higher than 20,22 I don’t seem to find a solution, certainly because I didn’t set it up right, I’m using the v3.3.10 version of this package
Also Whenever I click on a targetPosition with my mouse, the character doesnt seem to be centered on that position point, it is instead close to it, I tried to set “Exact End Point” in the Seeker Component to “Original” and “SnapToNode” even “ClosestOnNode” still not working the way intended.
For the centering problem, I noticed i’m not the only one who’s having it, and no solution was exposed, maybe people don’t mind that their player is not centered in the targetPosition, but in the game genre i’m making pixels matter, so if you have any suggestion please answer me I need help.
What I’m thinking of is adding a new waypoint that is ahead of the last one with a distance equal to the value my character seems to be far from the targetposition, so when it reaches the “cloned waypoint” it stands on the actual targetPosition, but I believe there is better solution.
My Character has these components : FunnelModifier Seeker RVOController PlayerMovementScript CapsuleCollider
As shown in these link : http://tinyurl.com/kpff744 (redict to dropbox)
Here is the code I’m using on my Character to make it move:
`
using UnityEngine;
using System.Collections;
using Pathfinding;
public class PlayerMovement : MonoBehaviour {
private Transform _myT;
private Seeker seeker;
private RVOController controller;
private Path path;
private int currentWaypoint = 0;
public float speed = 50;
public int nextWaypointDistance = 1;
private Vector3 targetPosition;
// Use this for initialization
void Start () {
seeker = GetComponent<Seeker>();
controller = GetComponent<RVOController>();
controller.mask = 12;
targetPosition = transform.position;
_myT = transform;
}
// Update is called once per frame
void Update () {
DetectMouseClick();
if (path == null) {
controller.Move (Vector3.zero);
return;
}
if (currentWaypoint >= path.vectorPath.Count) {
controller.Move (Vector3.zero);
return;
}
//Direction to the next waypoint
Vector3 dir = (path.vectorPath[currentWaypoint]-transform.position).normalized;
dir *= speed * Time.fixedDeltaTime;
controller.Move (dir * speed);
Vector3 rot = path.vectorPath[currentWaypoint];
if (Vector3.Distance (transform.position,path.vectorPath[currentWaypoint]) < nextWaypointDistance) {
currentWaypoint++;
return;
}
}
public void OnPathComplete (Path p) {
if (!p.error)
{
path = p;
currentWaypoint = 0;
}
}
//MouseMovementsToTargetALocationOnPlane
void DetectMouseClick()
{
if(Input.GetMouseButtonUp(1)) //Right click to move
{
Ray ray = (Camera.main.ScreenPointToRay(Input.mousePosition));
RaycastHit[] hitInfos = Physics.RaycastAll(ray);
for(int i = 0; i < hitInfos.Length; i++)
{
if (hitInfos[i].transform.tag == "Ground")
{
targetPosition = hitInfos[i].point;
seeker.StartPath (transform.position,targetPosition, OnPathComplete);
Debug.Log(targetPosition);
}
}
}
}
}
`
Many thanks for your time.