Grandtheft Auto style map

Community Forums/General Help/Grandtheft Auto style map

(tu) ENAY(Posted 2012) [#1]
Ok, I have my sort of GTA style mini map all made up, I am almost there, but for some reason I am having trouble thinking about the code to get an item locked inside the circle.

For example when an object is within range it moves around in your circular map but when it goes out of range, I want the object to stay inside the circle. I have written some code which can find a point along a straight line on 2 vectors, but that only returns the value of the length between 0.0 and 1.0.

Any ideas :)


GfK(Posted 2012) [#2]
You probably need to multiply the vectors by the radius of the circle, then add the X/Y coordinates of the centre of the circle/map to get true x/y coordinates.


(tu) ENAY(Posted 2012) [#3]
That's what I had, exactly what you said, doesn't seem to be working yet. I think I am close though. I just worked out how to rotate a vector by 45 degrees from a pivot :)


(tu) ENAY(Posted 2012) [#4]
Nope I can't figure it out, stupid thing. >:(

[edit]

Fixed it, it doesn't help when you mistakenly get a single X and Y the wrong way around does it?!

/me SELF FACE PALM x100

Last edited 2012


D4NM4N(Posted 2012) [#5]
what about using some hidden entities (ie, pivots) that move from your central point, with other objects using a virtual scaled position of what they represent, then use "entitydistance" command to detect radius.
Then you can use a so called "vertical dimension view" of them to get and set their X/Z coordinates. To keep them on the edge of the circle you could use pointentity to get the vector and then "moveentity" in Z it until it hits the radius of the entitydistance.

I did something like this to do a radar view for someone once.

You could even use visible objects to make it an actual on screen feature as the radar graphic itself. (swapping y for z obviously)

Last edited 2012


(tu) ENAY(Posted 2012) [#6]
Hi D4NM4N, thanks for the post and sorry that I didn't see this.

Luckily I got everything working perfectly in the end, this was in C# and Unity so I didn't have access to things like "entitydistance" and "pointentity" plus I needed to keep the code as portable between other languages as possible.

In the end (as ever) it was just my own stupid fault after all.


D4NM4N(Posted 2012) [#7]
lol yeah i can see that being a problem :D
I am surprised unity does not have some sort of replacement though :o


(tu) ENAY(Posted 2012) [#8]
It does have a render to texture sort of functionality but for what we are doing is a bit overkill, especially since we are aiming at mobile devices.