that’s not particularly easy.
I’ll tell you the simplest idea to get this done and move on…
To be clear you only need UP TO THREE LAYERS, correct?
Ok here’s what to do. LOOK at any one number. Let’s say 23.
You have to write down the “MOVE” for 23.
For 22, the “MOVE” is in fact -2,+3 . you get it?
For 7 the MOVE is +1, -1
ok?
Now do this.
private var moves:Vector2[] =
[
Vector2( 2,-1 ), // 0
Vector2( 2,2 ), // 1
Vector2( 0,-1 ) , // 2
.. etc .. do all of them up to 47 ...
.. etc .. do all of them up to 47 ...
.. etc .. do all of them up to 47 ...
];
You understand how to do the rest right?
Just make sure you have the local forward. Whatever your gap between them is (say 0.4 or whatever), just multiply by that. So it’s like …
for say number 15 …
goThisFarRight = moves[15].x * 0.40;
goThisFarUp = moves[15].y * 0.40;
So those two are how far you move “15” from the “H” hero.
You could easily write a logical procedure that gives them to you, but it would be pointless because I guess you want the flexibility of knowing the layout your are using (ie, the one you drew)
I hope this does the trick ! Cheers! K.I.S.S. … very important!
BTW
If you TRULY want a random position on layer N, it’s just this
function randomOnLayer(n:int ):Vector2
{
if (Random.Range(0,2)==0)
return Vector2(Random.Range(-n,n+1),n*(Random.Range(1,3)*2-3));
else
return Vector2(n*(Random.Range(1,3)*2-3),Random.Range(-n,n+1));
}
but really I recommend the “moves array” above.