News Forums RAIN General Discussion and Troubleshooting Cannot alter ai.Body's transform in custom Action

This topic contains 1 reply, has 2 voices, and was last updated by  Sigil 6 months, 1 week ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #35010


    Hi Everyone,

    I have been working on an app for a while and have recently realized that Rain may solve some problems I’m having and expedite some other solutions.

    Currently, I am tryin something simple: moving a cube using a custom action and the the Translate() function from MonoBhavior. However, It doesn’t move. Is the Motor interferring? I have used this kind of motion a lot in the past and it works so I know that I am doing it correctly.

    The node is definitely being entered as I am getting the Debug.Log message in my console but the ai.Body doesn’t respond to any rotations, translations or scaling.

    Please see my custom action’s code below:

    public override ActionResult Execute(RAIN.Core.AI a_oAi)
        a_oAi.Body.transform.Translate(a_oAi.Body.transform.forward * 0.1f);
        return ActionResult.SUCCESS;


    The motor is indeed interfering with your movement. Just for some added information, the AI copies the transform into its kinematic structure (AI.Kinematic) and after all the behavior and motion occurs it applies the changes from that to the transform. In your case it overwrites your changes since it didn’t know about them.

    You could work with the kinematic directly to apply your changes, or you can use the motor to move your body. I recommend you use the motor as that will do path finding and use your AI’s speed. You probably don’t need a custom action for this particular setup (move node would work perfectly), but as a test (or if you need something custom) you should be able to do

    a_oAI.Motor.MoveTo(a_oAi.Body.transform.position + a_oAi.Body.transform.forward);

    Let me know if you have any more questions.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.