- Home /
Image as a map, clicking on it spawns Gameobject in the scene at that position.
I'd like to implement map with settable waypoints by clickin somewhere on the map and spawning GO at that location. Ideas appreciated. I have compass it only needs a target to point to. someone pointed out getting xy of image and converting it to xy of world but the map is not rectangle its teared paper so i guess no go ? : ) thanks J
Answer by tormentoarmagedoom · May 13, 2019 at 02:12 PM
Hello. I don't know if there is any way faster o more simple, but this works, i did it a lot of times. Follow the logic...:
If you have 2 empty objects, with exactly same transform. Lets call them MapFrame1 and MapFrame2.
Then, each MapFrame have as a child the map itself, the real map (called Map1 and Map2), also with same transform properties.
Then you scale MapFrame1 to (0.1f ,0.1f, 0.1f)
If you perform a raycast in the Mapframe1, detect the hit, create a emtyobject (called for example PositionDetector) in that worldposition.
Then make this PositionDetector child of MapFrame1....
Create an EmptyObject (Called PositionFinder) as a child of MapFrame2.
And Finally:
PositionFinder.transform.localPosition = PositionDetector.transform.localPosition
Both Objects (PositionFinder & PositionDetector) will be in same place relative to the map. So you can use this PositionFinder as a reference to spwan what you really want.
Bye ! :D
PS: You should make the $$anonymous$$ini$$anonymous$$ap a mesh, (i never tried with an image, i dont know if works the same as a mesh...
uf, i am sorry but,... hhh, (i'm gonna number your dot statements) 1) empty objects as in , regular empty Go's ? not part of canvas or anything? 2) what is the "map itself" and what is "real map". i'm afraid i don't understand a word . :) hah p.s. what $$anonymous$$imap, i dont have one . just for clarity though
Your answer
Follow this Question
Related Questions
Grand theft auto - Map Waypoint 1 Answer
Assigning UV Map to model at runtime 0 Answers
how to create a waypoint? 2 Answers
Help with a simple AI 2 Answers