Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Kevron on May 27, 2013, 04:48:29 AM
-
Hi, and thanks for fantastic good work on Mecanim Animator. I have downloaded and tested the current package found here: https://hutonggames.fogbugz.com/default.asp?W1031
I am only wondering how far away "Navmesh agent" is to be released?
Best regards,
TorM
-
This is the script that is used to communicate to the NevMeshAgent.
Is it possible to remake it with Playmaker, or does it need some custom actions to work?
using UnityEngine;
using System.Collections;
public class Agent : MonoBehaviour {
public GameObject particle;
protected NavMeshAgent agent;
protected Animator animator;
protected Locomotion locomotion;
protected Object particleClone;
// Use this for initialization
void Start () {
agent = GetComponent<NavMeshAgent>();
agent.updateRotation = false;
animator = GetComponent<Animator>();
locomotion = new Locomotion(animator);
particleClone = null;
}
protected void SetDestination()
{
// Construct a ray from the current mouse coordinates
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit = new RaycastHit();
if (Physics.Raycast(ray, out hit))
{
if (particleClone != null)
{
GameObject.Destroy(particleClone);
particleClone = null;
}
// Create a particle if hit
Quaternion q = new Quaternion();
q.SetLookRotation(hit.normal, Vector3.forward);
particleClone = Instantiate(particle, hit.point, q);
agent.destination = hit.point;
}
}
protected void SetupAgentLocomotion()
{
if (AgentDone())
{
locomotion.Do(0, 0);
if (particleClone != null)
{
GameObject.Destroy(particleClone);
particleClone = null;
}
}
else
{
float speed = agent.desiredVelocity.magnitude;
Vector3 velocity = Quaternion.Inverse(transform.rotation) * agent.desiredVelocity;
float angle = Mathf.Atan2(velocity.x, velocity.z) * 180.0f / 3.14159f;
locomotion.Do(speed, angle);
}
}
void OnAnimatorMove()
{
agent.velocity = animator.deltaPosition / Time.deltaTime;
transform.rotation = animator.rootRotation;
}
protected bool AgentDone()
{
return !agent.pathPending && AgentStopping();
}
protected bool AgentStopping()
{
return agent.remainingDistance <= agent.stoppingDistance;
}
// Update is called once per frame
void Update ()
{
if (Input.GetButtonDown ("Fire1"))
SetDestination();
-
Hi,
Not far :) this week likely.
Bump this thread next week, if you don't get it. thanks.
bye,
Jean
-
Hi Jean,
Sorry to bump this two days earlier than you suggested, but I have some time now to work with this and wondered if you maybe already had finished the navmesh demo.
If not, I´ll just wait some more :)
Best,
Tor Martin
-
A little bump.
-
Hi,
Yes, coming up shortly, thanks for bumping,
bye,
Jean
-
Hi,
ok, navmesh demo implemented. you need to download the pro package, since indie license will not be able to run that, so I made two demos packages now to avoid issues.
https://hutonggames.fogbugz.com/default.asp?W1031
implementing the navmesh was a challenge, because it relied on features not implemented by the default PlayMaker set of Actions ( because it only work son Unity Pro, and only for Mecanim... lots of ifs...), so I made a custom action just for synching navMesh Agents that uses Mecanim. This should cover most cases I hope.
bye,
Jean
-
Thank you very much Jean, I will check it out and let you know how it works.
Best,
Tor Martin
-
The latest unity update gave us NavMesh for free. :)
-
Sorry to double post and bump, but I tried both packages with red errors to do with locomotion.
I was also wondering if per chance there would be any updates on the use of NavMesh in Unity Free, now that NavMesh is actually free! :)
-
Hi,
yes, navmesh will need a make over. I need first to polish pending work ( XML, Ultimate FPS Camera, NGUI), and then I'll deal with navmesh.
also, can you post the errors you get? I have used navmesh with locomotion when porting mecanim, and it was fine.
bye,
Jean
-
Hey there!
I know this is an older thread but since Navmesh is now available to indies (though i'm sure there are some extra features still pro-only) is this navmesh integration system going to work with an indie version if i import it?
I'd love to know and I want to say thank you for the work you're doing.
EDIT: Did some testing and I've determined that the navmesh system is working with the "set property" action without the system in there... apologies for asking this and necroposting.
I'll post a thread on how to integrate it when i've confirmed that this is working.
-
Hi,
Nice, thanks for catching up with this. don't hesitate to report features not accessible with set and get properties. I'll add them in my todos.
bye,
Jean