Hi, I have a question regarding the actor’s AI movement.
So I’m creating a sidescroller using 3d Mesh instead of Paper2d. I’m using Navmesh and Behaviour Tree to create AI behaviour.
Currently, the AI actor is constrained to the ZY axis plane, and only moves left and right. It can’t travel in depth (X).
However, I run into a problem when it comes to rotation. I currently have the AI character just wandering around in the ZY plane. The problem is sometimes they would Rotate and face X when they stop (meaning facing camera or away from camera instead of left or right). I’ve increased the rotation rate in Z to 70000 and it will still do that. Here’s a short gif to show my issue.
How do I constrain the actor’s rotation to only face 90 Degrees left or right? I’ve tried Setting actor’s rotation when Forward vector is > or < than 0 but to no avail.
Any tips or tricks will be greatly appreciated. Thanks!
Hello,
I do not know about 2D, but logically it’s the same;)
Get the character / pawn rotation, split the output node to float, take the Z and put InRange (float) from 0 to 180 for the right, one branch, is true setActorRotation 90, is false setActorRotation -90 …
After, it will not work with you can also use the directionVector 1Y or -1Y for rotate. If Z rotate does not work do not forget to tick use Z rotation in the Bp options of your Character / Pawn …
In my example i use Macro for futur Timeline, these are values for me, and the variable is not necessary … And at the end of the chain is a simple return node.
I hope it will help you a little …
Ps: There is probably something more simple to do, but I am a noob;)
I"ve tried using setActorRotation node but it doesn’t seem to override the behaviour. I’ve tried it in the actor’s BP and also it’s AI controller but to no avail. Currently the AI is moving using behaviour tree’s task, so I’m wondering if it’s something I need to do in Behaviour tree instead…