2
$\begingroup$

I am doing minimap and with script it should show You-are-here point with current position the only problem is - the red point is always shown outside of the minimap region, although it is moving correctly. but it should be on the location of a minimap!

what should i add to the simple code? screenshot attached enter image description here

$\endgroup$
4
  • $\begingroup$ Could you provide a blend file? This screenshot doesn't provide enough information, like the scene structure, what exactly is the globalDict["Pos"] (a list? If so, why dividing it?), etc. $\endgroup$
    – Joel Gomes
    Commented Jun 1, 2019 at 22:34
  • $\begingroup$ sorry for the size. Character from Scenebasic sceneuses script1 and the red pointer from HUD Screen scene uses script2. You may wait for up to a minute when press P. drive.google.com/open?id=1KxQPyPqYQFPLVRw-2kdhVNrswGzgyKQx $\endgroup$ Commented Jun 2, 2019 at 7:31
  • $\begingroup$ . in script1 i take worldposition xy axes of a Character and save it to a global variable Pos. $\endgroup$ Commented Jun 2, 2019 at 7:41
  • $\begingroup$ provided blend file $\endgroup$ Commented Jun 4, 2019 at 9:24

1 Answer 1

3
$\begingroup$

I've tried your blend file, but it's too heavy to work with. I've made an example file exclusively to answer your question. Download it here.

What you need to create a minimap is understand the concept of a viewport and make both minimap and game map the same size, so the dot position will work as expected.

enter image description here

How It Works

The basic concept of a minimap is:

  • Create a Minimap scene, and the minimap object must be the same size as the game map. In this example, both have 200 meters on each side (delimited by the black borders).

enter image description here

  • Add the Minimap as overlay scene.

enter image description here

  • Set the viewport from Minimap scene's camera. Everything is detailed on the script minimap.py.
# Enable viewport use on map camera
camera.useViewport = True

# Pre process the viewport pixel coordinates
left = getWindowWidth() // 2
bottom = getWindowHeight() // 2
right = getWindowWidth()
top = getWindowHeight()

# Set viewport coordinates
camera.setViewport(left, bottom, right, top)
  • Store the player's position and rotation on globalDict.
# Store player position and rotation on globalDict
globalDict['position'] = list(own.worldPosition)
globalDict['rotation'] = list(own.localOrientation.to_euler())
  • Update the arrow representation from minimap based on values from globalDict.
# Check if values are present in globalDict
if 'position' in globalDict.keys() and 'rotation' in globalDict.keys():

    # Update arrow's position and rotation
    own.worldPosition = globalDict['position']
    own.localOrientation = globalDict['rotation']

Additional Notes

  • Every object from Game scene is a group instance from scene _LibScenery.

  • The Minimap is added as overlay scene automatically at game start on object PlayerCollision from scene _LibScenery.

$\endgroup$
6
  • $\begingroup$ thank you. but how do i set the camera so high that to have the whole gameworld in aerial perspective like in your example? My gameworld is big and when i set the camera high, it stops showing anything on some altitude $\endgroup$ Commented Jul 26, 2019 at 21:05
  • 1
    $\begingroup$ @ArtemKuzmin Simply increase the camera clipping distance (Properties editor > Camera tab > Set to Orthographic and Clipping End to to a high value). $\endgroup$
    – Joel Gomes
    Commented Jul 27, 2019 at 13:13
  • $\begingroup$ thank you. i am doing something similar right now. could you probably help with this - blender.stackexchange.com/questions/146546/… $\endgroup$ Commented Jul 27, 2019 at 13:14
  • 1
    $\begingroup$ @ArtemKuzmin Go to the scene _LibScenery and switch the layers to find the original player, the one on the game scene is just a group instance. $\endgroup$
    – Joel Gomes
    Commented Aug 26, 2019 at 15:21
  • 1
    $\begingroup$ hey man i mentioned you in my Acknowledgement section here for my thesis. thanks. drive.google.com/open?id=1ehDAAdBpWApNsSO-4U3joegglQrTq4uT $\endgroup$ Commented Jan 14, 2020 at 14:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .