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$
  • $\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 da Silva Jun 1 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$ – Artem Kuzmin Jun 2 at 7:31
  • $\begingroup$ . in script1 i take worldposition xy axes of a Character and save it to a global variable Pos. $\endgroup$ – Artem Kuzmin Jun 2 at 7:41
  • $\begingroup$ provided blend file $\endgroup$ – Artem Kuzmin Jun 4 at 9:24
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$
  • $\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$ – Artem Kuzmin Jul 26 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 da Silva Jul 27 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$ – Artem Kuzmin Jul 27 at 13:14
  • $\begingroup$ hey could you tell me please how i can change moving the player from WASD keys to updownleftright keys $\endgroup$ – Artem Kuzmin Aug 26 at 10:52
  • 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 da Silva Aug 26 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.