Is it possible to modify the AILepr script so that the object does not rotate around the x and z axes?

The picture shows the work of two scripts AIPaz and AILepr. Is it possible to do this so that AILepr becomes a little like AIPaz? I understand that these are completely different scripts. It is necessary to make the object stand flat on the slopes.

If it’s possible, how can it be done?

aron_granberg Please help me one last time, I won’t bother you anymore. My knowledge is not enough to finalize your script. The enableRotation variable disables all axes. What can be changed in the script so that only one axis “Y” is unlocked, and the rest are locked.

Hi

You will have to do that using a separate script. Something like this might work:

void Update () {
     ai.enableRotation = false;
     var dir = ai.velocity;
     dir.y = 0;
     ai.rotation = Quaternion.LookRotation(dir);
}
1 Like

Thank you very much. I wanted to go to the extreme and draw the whole landscape, not model it. But this script needs to be finalized, otherwise it does not work well.

if (dir!=vector3.zero)
ai.rotation = Quaternion.LookRotation(dir);