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!
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.
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).
- Add the Minimap as overlay scene.
- Set the viewport from Minimap scene's camera. Everything is detailed on the script
# 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
# 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']
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.