AI Lerp, height problem

Using a Grid graph.
Using the AI Lerp script.

For various reasons the grid graph is flat, however not all the ground is flat. I would like to change the Y position depending where the character is but the value of the transform.position.y is always reset to 0 (because the grid graph not taking height into account no doubt), but do need to modify the y position of the character without it getting reset.

Is there anywhere in the code that I change, so that it so that it keeps the Y position of the transform?

Do you think you could post a screenshot of the grid graph settings?

In that case you should use the AIPath movement script instead of the AILerp movement script.
AILerp will just interpolate along the path without any option to use e.g. physics for the y coordinate.

The AIPath script has ground raycasting built-in.


Also. If you want the grid graph to respect the terrain’s height you should enable the Height Testing option.

Thank you for your quick response.

I ended up fixing my issue by adding the setting the Y position in the MovementUpdate() function to the transforms current Y position. This way I can change it through my other script.

I prefer this option over the enabling height testing and using the AIPath, however your reply is appreciated.

1 Like