Seeing this thread leaves me consufed
What is this thread about?
Seeing this thread leaves me consufed
What is this thread about?
NavMesh?
My navmeshAgent doesn’t move despite using agent.setDestination(). I placed it in Update().
??
Oooo. Now I get it! Never thought about that. Thanks
Could be renamed to “NavMesh”
Did you set its speed to more than 0? Did you check if the path was unvalid?
I got it working, I was using an y value that was not located on the mesh… at least I think that is the reason.
However, I have a new issue. My agent does not move in two z directions. Only one. So I tap screen, convert to world space, move agent. He will move away from cam, but never towards.
void setMoveToPos(Vector2 moveToPos){
Vector3 worldPos = Cam_Main.ScreenToWorldPoint(new Vector3(moveToPos.x, moveToPos.y, -18.6f));
targetPoint = new Vector3(-worldPos.x, worldPos.y, agent.transform.position.z);
moveActive = true;
}
Answer…
Use raycast, hit.point.
I imported a level as one hole mesh and added this script to it.
Well I get to “Debug.Log(“We click on nothing!”);”
I tried changing the front and rear clip planes of the camera. Static none static…
First I thought it was me scaling the mesh that was the problem. Later I scaled it in 3dsmax and used Xform before exporting it to FBX format. I export the level as four meshes under the same parent.
I use 3dsmax 2010, Unity 5 b14 on Windows 64 bit.
To test I introduce a Unity plane and add the same script to it. Then the script works, like ray testing don’t work on imported poly soup meshes…
usingUnityEngine;
usingSystem.Collections;
publicclassClickSetPosition : MonoBehaviour {
private GameObjectgo = null;
private PropertiesAndCoroutinessn = null;
voidAwake()
{
Debug.Log (“Awake started”);
go = GameObject.Find(“MyCube”);
if (go == null)
{
Debug.Log (“find couldn’t find MyCube”);
}
else
{
Debug.Log (“MyCube was found using Find.”);
sn = go.GetComponent ();
}
//other = (PropertiesAndCoroutines) go.GetComponent(typeof(PropertiesAndCoroutines));
Debug.Log (“onAwake ended”);
}
void Update()
{
if (Input.GetMouseButtonDown(0))
{
System.Console.WriteLine(“Entered game settings menu.”);
Debug.Log (“Mouse button down next make ray.”);
Rayray = Camera.main.ScreenPointToRay (Input.mousePosition);
Debug.Log (“Now try physics and Raycast to get RaycastHit…”);
RaycastHithit;
boolresult = Physics.Raycast(ray, outhit);
Debug.DrawLine(Camera.main.transform.position, hit.point, Color.red);
if (result == false)
{
Debug.Log(“We click on nothing!”);
}
else
{
Debug.Log (“OK physics worked and we clicked on something, see if we got the plane…”);
if (hit.collider.gameObject == gameObject)
{
Debug.Log (“hit!”);
if (sn == null)
{
Debug.Log (“Couldn’t get script sn == null !!!”);
}
else
{
Debug.Log (“Found script! Using it!”);
sn.Target = hit.point;
Debug.Log (“Success!!”);
}
}
}
}
}
OK add Mesh collider component to all level parts imported solved this.
My scenes will tend to have few static obstacles (or none), and only a handful of dynamically placed obstacles on a flat plane. Is it worth using Navmesh or should I just create my own simple navigation code?
FSL: