News › Forums › RAIN › General Discussion and Troubleshooting › how to stop the AI movement?
This topic contains 12 replies, has 2 voices, and was last updated by prime 2 years, 2 months ago.
-
AuthorPosts
-
January 6, 2023 at 10:12 am #6152
In rain 1.x, I can set RainAgent.maxSpeed = 0; RainAgent.maxRotationRate = 0; to stop AI movement during Move Node.
But In rain 2.0.8, AiRig.AI.Motor.Speed = 0; AiRig.AI.Motor.RotationSpeed = 0; doesn’t work.January 6, 2023 at 2:04 pm #6153Can you be more specific? I just ran a few tests and it seems to work fine for me.
January 6, 2023 at 4:10 pm #6158btw, I am using my custom navgiator class which only return next waypoint, is there anything I need to implement?
I will try to use the RainNavgiator to test again.January 6, 2023 at 5:00 pm #6162Shouldn’t matter. The Motor controls movement speed. The Navigator only provides move targets. Note that setting a Default Movement Speed will not limit your motion. In RAIN Indie the value was a Max (limiter). There is no equivalent in RAIN. If your code or your BT Move node specifies a different speed, that’s what will be used.
January 6, 2023 at 5:11 pm #6164how can my code change the speed of AI.Motor ?
void OnGUI()
{
if ( GUI.Button(new Rect(0,0,50,50), “Stop”) )
{
aiRig.AI.Motor.Speed = 0;
}
}However, the aiRig.AI.Motor.Speed become 1 in the next frame.
January 6, 2023 at 8:23 pm #6165Are you running a behavior tree that is Moving the AI at a speed of 1? Is some other code changing it? Unless the AI is being reset, the default value is not re-applied.
January 7, 2023 at 3:30 am #6174the speed is not set on Move Node.
I am using rain 2.0.8 ( fresh update from 2.0.5 ) + Unity 4.3.1
BT:
root
|-timer ( 3 sec )
|-get random target ( set variable “movetarget” to random position ) )
|-move ( Move Target: movetarget )AIRig use all Basic Components( BasicMemory, BasicMind, BasicMotor, BasicNavigator etc )
The following link is my test project
https://dl.dropboxusercontent.com/u/9322397/RAIN/Test2.0.8.zipJanuary 7, 2023 at 5:31 pm #6182Right… Sorry, I didn’t give the correct information about how movement speed works.
If you are using a Behavior Tree Move node, the node will determine move speed in the following way:
- If the move speed field is left blank, then the default AI speed is used
- If the move speed field is invalid (bad expression, etc.) then the default AI speed is used
- If the move speed field has a valid value (constant, calculated expression, or variable) then the field value is used.In your case, use a variable in your BT move node for speed. Then stop the AI by setting that variable to 0.
January 7, 2023 at 5:32 pm #6183By “default AI speed” I mean the Motor Default Speed.
January 8, 2023 at 7:57 am #6205Why don’t rain2.x not having MaxSpeed or MaxRotation like rain1.x, what you suggested in last post is quite time consuming that all move node in all BT need to assign a variable.
January 9, 2023 at 6:19 pm #6243You don’t have to assign a variable. If you assign nothing, it uses default speed. If that isn’t what you want, then of course you have to tell RAIN what you do want…
January 10, 2023 at 2:36 pm #6278Default speed cannot be changed during runtime, what I want is having MaxSpeed and MaxRotation in rain 2.x
January 10, 2023 at 3:34 pm #6280Default speed can be changed at runtime.
-
AuthorPosts
You must be logged in to reply to this topic.