Steering behaviours and wrap-around worlds

Started by
11 comments, last by Timkin 18 years ago
Hey man, take it easy...
I withdraw my previous statement "which doesn't work", and replace it with the more accurate version "which solves a problem which likely is different from what the OP was talking about".
I didn't write the long version, because it didn't explain the humour I saw in it.

Let's forget about that and get back on-topic...

XiotexStudios, if you're still looking for a solution, then this might help:

halfworld = worldsize / 2; targetX = player.x; if (targetX < (agent.x - halfworld))	targetX += worldsize;if (targetX > (agent.x + halfworld))	targetX -= worldsize;targetX -= agent.x;targetY = player.y - agent.y; Move_In_Direction(Get_Direction_To(targetX, targetY));


The 2 if-statements, plus the following 2 lines, is what converts the players coordinate to agent-space. The Get_Dir_To()-function calculates a direction from coordinate 0:0 towards the supplied parameter.
You are probably already using such a function, and only need to modify it to assume that the from-coordinate is always at 0:0.

Good luck!
----------------------~NQ - semi-pro graphical artist and hobbyist programmer
Advertisement
Thanks - I'll give it a go..
Byron Atkinson-JonesXiotex Studioswww.xiotex.com
Quote:Original post by NQ
I withdraw my previous statement "which doesn't work", and replace it with the more accurate version "which solves a problem which likely is different from what the OP was talking about".


*sigh*.

If you have evidence as to any error in what I wrote, then please post it. If not, then your opinions are based only on supposition and misunderstanding and are therefore inappropriate and inflammatory. Please do not treat other forums users in this manner.

Timkin

This topic is closed to new replies.

Advertisement