News › Forums › RAIN › General Discussion and Troubleshooting › New to RAIN and in need of help
This topic contains 13 replies, has 2 voices, and was last updated by bnolte 1 year, 9 months ago.
March 9, 2022 at 5:49 am #36523
I just started with RAIN a couple days ago. I have looked over the tutorials and watched some videos to try and learn things.
Currently I am having a great deal of problems with mechanim animations. I watched the video about this many times but things simple do not match up.
So far I have imported my model and applied a humanoid rig.
Created a basic animator controller with 2 states Idle and Walk. Each of these use animations from the Unity asset store mechanim asset. These are just states with no blend trees and a tag on each with their respective state name as I found it easier for me to reference the mechanim tag instead of the layer name state. The transition state is set to check the Speed parameter and the animations will play on the model.
When I add a single state with a start parameter to set the Speed to 1.0 and a stop parameter of Speed to 0.0 and the behavior tree calls the animation the speed is set to 1 and the character walks. However when the animation completes the speed variable is never set to 0 and the character walks until the scene is stopped.
The next issue I have is that if I add another state adding the Idle state and a start parameter of speed 0.0 and stop parameter speed = 0.0 then when the animation attempts to call that state it returns a failure. It is as if I am only allowed to have one state added.
Any suggestions? I am sure I am just missing something simple.
Thank youMarch 9, 2022 at 8:02 am #36525
First suggestion is to avoid using the RAINAnimator to control your mecanim animations. You are better off controlling them in two ways:
[To follow these instructions, make sure you are looking at the Advanced View in RAIN. Click on the gear icon next to the RAIN AI inspector and choose Show Advanced Settings.]
1) Use the Mecanim Motor to control locomotion/movement. In the Mecanim Motor, you can add parameters that are transmitted to the Mecanim state machine whenever the AI wants to move. For example, if you add the Speed parameter, then the Mecanim Motor will set the Mecanim Parameter “Speed” to the current AI speed in the state machine. In addition, if you are using Root Motion, just check the Use Root Motion box and RAIN will allow Mecanim to control the actual movement.
2) When you want to set parameters directly or control individual animations, use the Mecanim Set Parameter behavior tree node. From there you can activate a mecanim trigger or set some other parameter as needed.
Hope that helps.March 9, 2022 at 2:07 pm #36532
Thank you for responding. unfortunately I still am lost.
I removed all animation states from the mecanimanimator.
added a mecanimmotor and added the parameter of speed.
At this point the character will simply stand and idle as expected.
In the behavior editor I clear everything out and add an action of move setting the move target to the Navigation point of “North”.
I leave the move speed blank as I want to use the default value of the macanimmotor and set the close enough distance and angle to 0.1
at this point the character will still only stand and idle.
Perhaps I am confused as I thought the move command in the behavior would tell the character to go to that navigation point and the mecanimmotor would take over using the root motion to walk to that point.March 9, 2022 at 4:24 pm #36536
Is your Mecanim Motor set to use root motion?March 10, 2022 at 4:49 am #36542
YesMarch 10, 2022 at 7:54 am #36547
You will need to define a transition from your idle to your walking state based on the Speed parameter. (e.g., transition to walking if speed > 0.1 and transition back to idle if speed < 0.1) Also, since you only have a simple setup, you will need to check the "Override Root Motion Rotation" box on your Mecanim Motor. If you don't do that, RAIN will be expecting your state machine to control direction/steering. One last thing - you may want to set your Face Before Move angle to 360 to allow the character to start moving immediately rather than spinning in place while until it is facing the right direction.March 10, 2022 at 1:41 pm #36561
Thank you for you patience in helping me prime.
So far what you have said is helping lot. I added the override root motion and things are pretty good.
The issue I see now is waiting for an animation to complete and no breaking out of them. Currently I have the idle and the walk animations. I have a navigation point set and in the behavior tree a single move action call to that navigation point.
the behavior tree shows the move action as running but the character stands there until the idle animation is complete. Then the character will walk correctly to the navigation point. Once at the navigation point the character will continue until the walk animation is complete. The character will run the idle animation until complete then walk one iteration due to the overshot of the position as a result of the walk animation. This will continue switching between the animation states.
How can I allow the move state to interrupt the idle state and if possible have the walk state end prematurely once the target is reached (or do I have no choice other than to increase the close enough variable on the motor?)March 11, 2022 at 8:38 am #36580
Generally that has to do with how the transitions are set up between the animation states. Can you send over the project you are working on? I can take a quick look and possibly help nudge you forward.March 11, 2022 at 8:47 am #36582
I will need to create a “watered down” project for you as he actual project is a little bulky due to connection to a database for user log in and character selection which you would not need.
Where can I send the project to?March 11, 2022 at 8:54 am #36585
Contact email@example.com and he can help arrange it. Thanks.March 11, 2022 at 9:09 am #36587
Thanks again for all of your help. You last post about handled in the transition was what I needed. I was messing with different things and it was very easy to fix. I had the Has exit time checked. By turning this off the animation will cycle as desired so once the target reaches the point the animation stops immediately.March 12, 2022 at 10:45 am #36625
Since this was a bit of a generic thread in the first place I was going to go ahead and add another question here.
At a glance things to be looking good. I added a new layer labeled obstacles.
Imported a model with mesh colliders
added 3 unity primitive cubes with collision boxes.
Set the above objects to the obtacles layer.
The step height on the mechanim motor is at the default of 0.75 so I set the heigh of each of the 3 cubes to increment by 0.5 so they create a small set of steps.
I generate a navmesh which includes just the ground and obstacles layers.
The mesh looks a little odd. The model I imported is basically a simple “house” with a doorway and a t-section wall. The navigation mesh is purple and shows on the ground but not on the model.
The navmesh also shows as a ramp for the first step with a small angled plane between the next steps. So it appears I would be able to ramp up.
When I run it. The character will navigate the “house” avoiding the walls to and from the nav point as desired. however when it goes to the steps the character will pass right through the steps as if there is no collision detection.
The model has a box collider. 3d movement is selected and the steps each have box colliders.
What am I missing to allow the mecanim driven character to go up and down steps?March 12, 2022 at 1:36 pm #36629
Navmesh settings don’t impact whether a character can move up and down steps. They only help the generator create an appropriate navmesh for characters that have those attributes. So a step height of .75 means you expect your character to be able to step up or over things that are that tall. It’s up to you to create a character that can actually do it.
There aren’t any default characters or settings that are going to let you walk up a set of stairs at 0.5 height (unless everything else is scaled up significantly). However, independent of that, if you want a character that attempts to obey collisions and step up height, I suggest using a Unity Character Controller instead of a box collider on the model. A Character Controller will help your character obey gravity and physics, and includes settings for slope and step up height.March 12, 2022 at 4:45 pm #36633
So once again Prime thank you,
Again this was something simple that if I wasn’t so new I probably would have known.
You must be logged in to reply to this topic.