News Forums RAIN Sample Projects, How To, and Code Combining Mecanim and RAIN: Part 1

This topic contains 29 replies, has 8 voices, and was last updated by  prime 10 months, 1 week ago.

Viewing 15 posts - 16 through 30 (of 30 total)
  • Author
    Posts
  • #34099

    Makarios
    Participant

    Using the completed tutorial scene, if I turn on root animation the animations look so smooth and timed right, but he just walks straight. If I turn the root animation checks off, then he follows the waypoints correctly but the animations look a little forced, turning on points, moving too quick for the turns, etc…

    #34101

    prime
    Keymaster

    there’s another checkbox for Override Root Motion Rotation. Do things look better when you check that box?

    #34149

    Makarios
    Participant

    found it and that does seem to fix the problem

    small detail but the title of that option is so long that it’s cut off, I was only seeing “Override Root Motion” originally until i expanded that region.

    Thank you for the help

    #34182

    Makarios
    Participant

    possibly a related problem so i’m going to post it here, I’ve got my click to move all setup, and character has a basic animate and move behavior taking him to where i click, but the problem is he never stops… if i click somewhere else he changes direction and heads to the new point, but he never stops when he gets there

    this wasnt a problem with patrolling, so I imagine there is an extra step involved in getting the character to stop when you want him to, will play with it some more later, but just in case it’s related to the root motion prob wanted to put it in here.

    #34194

    prime
    Keymaster

    Keep in mind that if you are using root motion for movement your positioning will be less precise than “meat hook” movement. The solution may be to increase the close enough distance on your motor.

    #34324

    Makarios
    Participant

    tried close enough distance .5, 1, 2 no change

    when i changed it to 10 the character started acting really funny and stopped responding to clicks

    I’m assuming from your response that I shouldnt have to give him a separate command to stop at the navigation point

    for a simple hold still until i click for you to move to point, move there and stop behavior, waypoint path is the type of node I would want to use correct?

    #34325

    prime
    Keymaster

    No, you certainly don’t want a very large close enough distance. If that were the problem, then something around 0.5-1.0 would have solved it.

    Is there a particular reason you need to use a waypoint path (or waypoints at all)? For a simple click to move behavior, you probably don’t need them.

    I’m not sure what the stopping issue is. Can you provide more info? Maybe a screen shot of the BT? Or export the BT to xml and send it over?

    #34332

    Makarios
    Participant

    I removed the waypoint path ( still new to AI, originally I thought it was needed for navigation )

    get the same results, only thing I’ve noticed that might be of help is that I can click all around and the character continues to turn and walk to the new points as I click, however, if I click and let him walk to and pass the clickpoint, he will no longer recognize new clicks he will just continue to walk in a straight line

    basically the animation speed never decreases again once I click, I click and it raises from 0 to .5 to get full walk speed, and then when he reaches the point it stays .5 and he just keeps right on going

    • This reply was modified 10 months, 1 week ago by  Makarios.
    • This reply was modified 10 months, 1 week ago by  Makarios.
    • This reply was modified 10 months, 1 week ago by  Makarios.
    #34341

    prime
    Keymaster

    Ok, a couple of things:

    1) In your parallel, the Move will eventually complete, but the animate will not. If your Parallel is set to Succeed on All (the default) then after the Move completes, the animation will play forever but the Move will never resume. If your Parallel is set to Succeed Any, then it will constantly play the animation anyway (because the Parallel will keep happening) but shouldn’t move anywhere.

    2) If you are using Root Motion animation, then you don’t want to use a separate Animate node. Instead, you want to use a Mecanim Motor on your AI, then pass along speed and turning data to your Mecanim State Machine using the parameters you can add at the bottom of the Mecanim Motor inspector. Your BT will then just be a single move node.

    3) If you are not using Root Motion and you want the animate/move loop to work, do the following:
    (a) Put the parallel inside of a Sequencer
    (b) Add an Expression to the sequencer before the parallel. Set it to pcmovepoint != null and the return type to Evaluate.
    (c) Make the parallel Succeed on Any
    (d) Add an Expression that runs in the sequencer after the Parallel completes. Set it to pcmovepoint = null and set the return type to Success.

    So:
    SEQUENCER
    — Expression pcmovepoint != null returns Evaluate
    — Parallel that you already have. Succeeds on Any
    — Expression pcmovepoint = null returns Success

    This will make the move only run when you have a valid move to point. It will run until it reaches that point. After it succeeds, it will set the move to point back to null.

    4) Don’t forget to set your move speed to something other than 0 in your move node

    #34345

    Makarios
    Participant

    AHHA!

    still not quite there, but your last post helped a lot, I think now my remaining problems have to do with my limited understanding of animations, I was building my little test scene off this mecanim tutorial

    so my only 2 animation variables are AnimSpeed and Direction ( aside from Hi, which i’m not worried about )

    i tweeked my close enough distance on the move node to .15 (cause .1 caused it to begin walking circles when it got close sometimes)

    now it begins in idle with no movement, I click, it moves to point, animated, and stops when it reaches the point, the core of it is there

    how would I achieve things like damp time using this method? moving to the single move node, no animation node and using the sequencer to check for pcmovepoint != null makes the core work, but now it jumps from 0 speed to move speed and back to 0 with no damp which in many ways kills the benefit of root motion I’d like to damp both the start and the stop

    another thing, initially i put my direction variable into the “Param turn angle” on the mecanim motor, and it caused all kinds of graphical funk where any time he was walking generally straight it was frame by framing jumping causing a mirrored twin character affect where 2 characters with the same foot positions walked 1 angled left, 1 angled right … it looked normal when he held still, and normal during harsh turns, but graphic funk whenever he was relatively straight. I took out the direction variable entirely and again the core works, but i dont get the smoothed lean into turns animations, where would I put that to be correct? **edited note: when i put direction into the param turn angle he does seem to lean correctly, and looks normal in any case where he would lean, its as if when i put the variable in there it cant handle when the variable is 0 and tries to display both positive and negative (leaning both ways)… is the variable being set to null or something when not in use?

    • This reply was modified 10 months, 1 week ago by  Makarios.
    #34348

    prime
    Keymaster

    - Parameters in the Mecanim Motor do have a damp time on them, which may help a little. The damp time is passed on to Mecanim, which handles the actual damping. That said, we generally handle slowdown through the state machine and transition animations. In other words, once the AI is moving, going back to a stop may require going through a “walktoidle” animation.

    - The frame flicker (funk) may be happening for a number of reasons:
    1) If you are controlling turning through Mecanim, make sure you have a fairly loose CloseEnoughAngle. Root motion turning won’t be able to generate precise angles, so you don’t want the AI motor to constantly adjust.
    2) Make sure your root pivot doesn’t change on your animation when turning. One of the Unity mecanim samples suffered from this problem and made it nearly impossible for RAIN to determine which direction the character was facing. This isn’t normally an issue, but if you are using one of Unity’s models for testing you might be running into it.

    #34357

    Makarios
    Participant

    1. when you say parameters have a damp time, do you mean there’s a variable somewhere I’m not seeing where i could set it? or there’s just a default somewhere in the code that should be being applied? (cause right now I’ve zoomed a camera from a side view and it looks like there is 0 damp time right now ) - In the mecanim animator in AI there is a start parameter and stop parameter that allows a damp time, but it doesnt seem to be getting used right now cause i set AnimSpeed as the start and 1 and a damp time, but it never kicked in, it continued to move at the move speed of .5 not the AnimSpeed of 1 this would have caused… how can I use this start / stop parameter from here? could I set the start to set animspeed to 1 and the stop to set animspeed to 0 using this method?

    2. I played with the close enough angle some, no effect, even when making it very large like 10+, I think the problem may be related to my original question, I had to check override root motion rotation in order for the model to turn at all originally, if I didnt he only walked forward in a straight line. however now that I’ve changed my method to using the mecanim motor, I can now put direction variable into my turn param and uncheck override root motion rotation, and it now works and turns and does the slight angles when turning… however I still get the fram flicker (funk) very often whenever he is moving straight, no longer all the time, but even with a close enough angle of 50 about half the time he is just walking forward he still gets that flicker funk

    #34366

    prime
    Keymaster

    1) On the Mecanim Motor at the bottom of its inspector, you can add parameters that are forwarded to the state machine. When you do that, you specify what data RAIN will send (Speed, Turn Angle, etc.) and the name of your state machine parameter that should receive the value. You can also specify a damp time there. You don’t want to be dealing with the Mecanim Animator for this, just the Motor.

    2) I’d have to see the flicker. It could be for any number of reasons. Is there another animation playing at the same time? Is the move node failing or getting interrupted? Could there be a problem with the state machine setup where it is dropping out of motion and resetting constantly?

    #34375

    Makarios
    Participant

    could you show me the syntax for passing these parameters you talk about? for example if I want to pass a speed of 1 with a damp time of .25 to the state machines “AnimSpeed” parameter, how would I do that?

    I tried to get a screenshot of the flicker problem originally, but because it’s frame by frame back and forth my screen shots look normal cause they only catch the 1 frame where he leans in 1 direction, looking pretty normal, when it flickers the move node seems to continue to work correctly, he just flickers his way in a straight line to the end point where he stops moving and stops flickering, it is only during straight movement, and only half of more of that time, that the flicker happens.

    #34380

    prime
    Keymaster

    There’s no syntax. There are 2 ways to send data to mecanim here:

    1) At the bottom of the Mecanim Motor inspector there is a drop down field. From it you can select what information you want to send to Mecanim. In your case, you probably want Speed. Once you add that parameter, set the parameter name to AnimSpeed and damp time to 0.25. The actual value that will be sent to Mecanim will be the speed calculated by the motor. If that needs to be 1 or 0, then make sure the default movement speed of the motor is set to 1

    2) If you don’t want to do it from the motor, you can add a Mecanim Parameter node to your behavior tree. The node lets you set the name of the parameter - “AnimSpeed”, the type - float, the value - 1, and a damp time - 0.25 This node will return immediately with success, so you will probably want to force it to repeat as long as you are moving.

Viewing 15 posts - 16 through 30 (of 30 total)

You must be logged in to reply to this topic.