playMaker

Author Topic: Navmesh and mecanim  (Read 4611 times)

Arnoob

  • Junior Playmaker
  • **
  • Posts: 60
    • View Profile
Navmesh and mecanim
« on: April 30, 2015, 06:02:18 AM »
Hello everyone. First, as it is my first post on the forum i'd like to thank the creators of playmakers, they really made programming possible for me  :D

The forum has been really helpfull for me to troubleshoot any problem I encountered untill now,but right now, I'm stuck on a problem I can't figure out.
I'm currently trying to link an AI (with a navmeshagent) with the animator.

The thing is, to do so I need to find a way to calculate in real time what is the speed and the anglerotationspeed of this game object, but I can't find how.

In the Unity documentation, they explain how to do it with script file:///E:/Program%20Files/Unity/Editor/Data/Documentation/en/Manual/nav-CouplingAnimationAndNavigation.html, but I'd like to be able to do it with FSMs, as it would certainly explain me how to do some other thing laters.

Also, is there a playmaker version of the Enemy AI of the stealth minigame? I found the ethan's version, but not the robot.

Anyway thank you a lot and have a good day!  :)

mdotstrange

  • Hero Member
  • *****
  • Posts: 549
    • View Profile
    • Can't code? Who cares! Make games anyway!
Re: Navmesh and mecanim
« Reply #1 on: April 30, 2015, 07:21:19 AM »
You can use "Get Game Object Speed" from Eco-system to get the speed and pipe that into a Mecanim parameter-

For the rotation- this "get angular velocity" should do it http://hutonggames.com/playmakerforum/index.php?topic=2493.0 If not check out Jean's Quaternion action set linked in that post
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

Arnoob

  • Junior Playmaker
  • **
  • Posts: 60
    • View Profile
Re: Navmesh and mecanim
« Reply #2 on: April 30, 2015, 08:34:36 AM »
Thank you for answering mdotstrange.  :)

Well, I figured out a way to get the speed with the "get property" action off the navmeshagent, and storing the velocity.magnitude in a float.

Now I'm trying to do the same for rotation. I don't really understand what is going on in your link as I'm not familiar with the quaterion/euler variables.
Could you please link me a tutorial about it in playmaker? I only find tutorials about it with scripts for now...

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13518
  • Official Playmaker Support
    • View Profile
Re: Navmesh and mecanim
« Reply #3 on: April 30, 2015, 10:31:11 PM »
Hi,

 just a double check. you are aware there is a support package for Pathfinding on the PlayMaker wiki?

https://hutonggames.fogbugz.com/default.asp?W1174

Bye,

 Jean

Arnoob

  • Junior Playmaker
  • **
  • Posts: 60
    • View Profile
Re: Navmesh and mecanim
« Reply #4 on: May 03, 2015, 09:57:23 AM »
Hi Jeanfabre.

Yes, I already download these great assets, many thanks to their creator by the way.
However I would recommend updating the wiki about these new actions. Almost all of them send me to a "no found" in the index. If you want I can help you updating it by describing those I already figured out by try/fail.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13518
  • Official Playmaker Support
    • View Profile
Re: Navmesh and mecanim
« Reply #5 on: May 06, 2015, 07:13:52 AM »
Hi,

what do you mean? I am not sure I understand, what you mean by "index"


 Bye,

 Jean

Arnoob

  • Junior Playmaker
  • **
  • Posts: 60
    • View Profile
Re: Navmesh and mecanim
« Reply #6 on: May 29, 2015, 11:56:09 AM »
Hello Jean, and sorry for the very late answer.
By the index, I meant the link we're sent to when we click the question mark under an action, like here https://hutonggames.fogbugz.com/default.asp?ixWiki=1&pg=pgSearchWiki&qWiki=title:Nav%20Mesh%20Agent%20Animator%20Synchronizer.

I have new questions about the mecanim/navmesh combination, but first, I'll share what I found in case other users need infos.

To get the rotation of a navmeshagent, you can get the localRotation.y from its transform in a float with the "getproperty" action. Then do it again in an other float after a certain amount of time (using a "wait" action and an other state) and substract these two floats. You now have a "rotation over time" float that you can use to tell to the animator (with the "set animator float" action) what is the rotation speed .
Do the same for the velocity (again with the "getproperty" action) and you can now set moving and turning animations according to your navmeshagent.

The thing is, with this technique, you have the navmesh that sets up the movement, and the animator comes after (without root motion).
What I'd like, would be to be able to do the opposite = having the navmesh agent to set up a destination, then having the animator to "choose" the animation with root motion to move the animator.

In the unity documentation, here is what is written :
Quote
Agent follows animation :
- Disable NavMeshAgent.updatePosition and NavMeshAgent.updateRotation to detach the simulation from the game objects locations
- Use the difference between the simulated agent’s position (NavMeshAgent.nextPosition) and animation root (Animator.rootPosition) to calculate controls for the animations
- See Coupling Animationfile:///E:/Program%20Files/Unity/Editor/Data/Documentation/en/Manual/nav-CouplingAnimationAndNavigation.html and Navigation for more details.

I'd like to know if you know a way to do it?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13518
  • Official Playmaker Support
    • View Profile
Re: Navmesh and mecanim
« Reply #7 on: June 23, 2015, 05:40:25 AM »
Hi,

 I think you can, but I haven't got a scene to test this out. do you have a working sample using scripting or something?

Bye,

 Jean