[SOLVED]characterControl and walkDirection with seeking

Something that’s been bugging me with my AI is some shoddy code I built up from the beginning using classification regions and large if statements for movement (using left, right, up and down).

Now this problem could solely be the fact I’m using characterControl for AI but just in case there’s a possibility to try fix what I want anyway:



I’m creating a vector from subtracting the bot position vector from the waypoint position vector, I then normalize this vector and multiply it by the speed to travel. (I ignore the Y axis)



If I use this vector as the parameter for walkDirection, as the bot gets closer to the target it slows down (I guess as it gets closer the vector gets smaller, so the steps get smaller). Setting the viewDirection to it also I get the bot viewing straight to the ground (much like viewing down with character controls slows the character down).



Other than the slowing down/viewing issue everything else is fine, movement is very smooth.

try something like

[java]

Vector3f direction = target.subtract(start);

//remove y component (leaning down)

vec.setY(0);

vec.normalizeLocal();

vec.multLocal(speed);

[/java]

Wheeey works :slight_smile: ty yet again



Had similar code but I wasn’t doing everything local.