Hi All,
I’m using A* Pro Beta 4.1.1, Unity 5.6.1f1.
I need help to fix my character, it’s spins around when getting to the target. Or sometimes it just get stuck in place and doesn’t move forward or behave like a rubber band, move forward and is just pushed back to original position.
I’ve setup my game as per example 6 Navmesh RichAI. I basically copied and paste most of the settings from there and made a few changes.
This is the TargetMover that I changed as I don’t need the other parts:
public class TargetMover : MonoBehaviour {
/** Mask for the raycast placement */
public LayerMask mask;
public Transform target;
RichAI[] ais;
Camera cam;
public void Start () {
//Cache the Main Camera
cam = Camera.main;
ais = FindObjectsOfType<RichAI>();
useGUILayout = false;
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown(0))
{
UpdateTargetPosition();
}
}
public void UpdateTargetPosition () {
Vector3 newPosition = Vector3.zero;
bool positionFound = false;
//Fire a ray through the scene at the mouse position and place the target where it hits
RaycastHit hit;
if (Physics.Raycast(cam.ScreenPointToRay(Input.mousePosition), out hit, Mathf.Infinity, mask)) {
newPosition = hit.point;
positionFound = true;
}
if (positionFound && newPosition != target.position) {
target.position = newPosition;
if (ais != null) {
for (int i = 0; i < ais.Length; i++) {
if (ais[i] != null) ais[i].UpdatePath();
}
}
}
}
}
I’ve attached pictures of the settings. I don’t have any script attached to the player or to the camera, that would trigger such behavior.
Here is a video where the weird behavior is shown.
Also, is there a way to make the rotation a bit smoother and not abrupt like in the video?
Please, help me to get this fixed as it’s a stopper on be able to make my game.
Thanks in advance…