Top-Down Mini-Map Live Update While Driving

0 favourites
  • 12 posts
From the Asset Store
Set of tiles to create a map for top-down games with island theme
  • I'm working on a top-down racing-style game in a sandbox cityscape. No major explanation for the minimap - it works like almost any of its sort if you're familiar with games like Need For Speed: Most Wanted or Spider-Man 2...all of which show a limited surrounding layout of your location.

    And, just like these mini-maps, as you move about, the icon that represents your character stays at the center of the mini-map while the rest of the icons for roads, buildings, etc move accordingly.

    UPDATE: I've gotten the minimap to move around and update accordingly. What does not work is getting the map to appear correctly given the player Car's literal position in the layout.

    I've managed to get the icons to appear in their proper location and size relative to the layout objects they represent.

    But what I cannot get to work properly is to have the icons on the mini-map move relative to how the car moves about the environment. I've checked the debug layout, and it shows the X & Y values for the icons as being waaaaaaay astronomical. Totally out of the limits of the layout.

    Parallax for the mini-map layout is 0x0, of course, but I'm not sure why the mini-map isn't working. Here's what I've got so far... https://www.dropbox.com/s/xt8w2rywggvvo30/The%20Getaway.c3p?dl=1

    Event lines to focus on: 3-6 and 29.

  • R0J0hound - Any suggestions?

  • I’m on my phone but I may have one idea. Could be vastly different to your project, idk.

    So I’m guessing you have something like this currently:

    Set marker position to minimap.x + enemy.x/32, minimap.y + enemy.y/32

    If the minimap is 1/32 scale

    Relative, just mean subtract the players position from the enemy position.

    Set marker position to minimap.x +(enemy.x-player.x)/32, minimap.y + (enemy.y-player.y)/32

  • I will give that a try. Thank you!

  • Alrighty... So, what you're sharing makes sense, but I think I failed to explain what I'm trying to do clearly.

    Pardon some redundancy...

    The minimap won't show the ENTIRE set of roads and buildings, etc. Just the immediate radius surrounding the player car. So, as the car moves and passes by buildings, the respective icon on the map will show the player car passing by a building. The car icon always dead-center in the map, of course. As mentioned, I'm able to get the building and road icons to appear appropriately on the map, but I'm having trouble figuring out how to get the icons to "move" on their layer (which is parallax 0x0). My efforts to use lerp have failed (kinda...).

    (Not that it matters much towards the problem I'm having, I have the icons set to a blend mode so that they ONLY appear while overlapping the minimap white outline object. Just in case that helps to set the picture as clearly as possible of what I'm attempting to do.)

    Thanks again for your time and patience.

  • Further update...

    My apologies, unless you haven't looked at my .c3p yet, one thing I didn't clarify about my set up is that I have another object on the minimap (which will be invisible) that all the map icons are pinned to (except for the one representing the player car.

    This object (with said icons) moves along the minimap outline to represent map movement as the car moves.

    SO FAR, since my last update, I've been able to get things to move. NOW my only problem is getting the INITIAL orientation of this object to appear correctly so that the car icon appears in the accurate position relative to the actual player car. Meaning, if the car is actually to the left of a building, the minimap still shows the car icon appearing somewhere...else.

    Here's the current action I have for the updated map icons...

    Set position for Map_BG object:

    X position -> lerp(HUDborderMiniMap.X-HUDborderMiniMap.Width/2,HUDborderMiniMap.X+HUDborderMiniMap.Width/2,1-unlerp(0,LayoutWidth,Car.X))

    Y position -> lerp(HUDborderMiniMap.X-HUDborderMiniMap.Height/2,HUDborderMiniMap.Y+HUDborderMiniMap.Height/2,1-unlerp(0,LayoutWidth,Car.Y))

    The idea here, as you can see, is to take the (un)lerp position of the player car object - with the ranges of the width and height of the layout - and use that fractional value to determine how to place the Map_BG object (which has all the minimap icons pinned to it). Thus making the minimap do what it's supposed to. Unfortunately, the best I've been able to do is to get the map to move appropriately but not show the car icon in the right place (which means the Map_BG object isn't updating accordingly). The link I provided in my original post should take you to the updated save file.

  • The idea I gave should still work. No need to use lerp, and it will automatically center the minimap on the player. This example just maps everything but you can add a distance check before adding things to the map.

    dropbox.com/s/zdtztrfrl4q7p1x/car_streets_minimap.capx

    I also was messing around with some traffic. No behaviors, and a manually laid out road map. Works decently, although the ai seems to have some road rage issues. They seem to like to tailgate, and slow down when someone is behind them, not to mention all the collisions. I was attempting for some more orderly stuff.

    Maybe useful for some ideas.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Forgive me...

    I'm just not getting it. Everything I've attempted so far - including using your solution - just isn't working.

    I tried to open your .capx but it's telling me there's something concerning the poly_pts and it won't load for me.

  • I hope this offers more clarity.

    Like I mentioned, the map moves in-sync with the movement of the player car, but it's "off center" from the actual location of the car.

    For instance, if the player car is to the bottom left of a building, the minimap shows the car is several units north of the building.

  • Ashley - I know you're busy, but do you have a moment to look over this?

  • The capx is working here. I don't know what's amiss.

    Here's basically the events. It's like my previous post, and it does what you're describing. The minimap is centered on the player and is scaled down from the level size. It creates markers from everything, but if you only want the buildings close, you can add another condition to the for each loops like:

    distance(building.x, building.y, player.x, player.y) > 200

    every tick
    -- destroy playerMarker
    -- destroy EnemyMarker
    -- destroy BuildingMarker
    -- create playerMarker at minimap.x, minimap.y
    -- playerMarker: set size to player.width/10, player.height/10
    -- playerMarker: set angle to player.angle
    
    
    for each building
    -- create buildingMarker at minimap.x +(building.x-player.x)/10, minimap.y + (building.y-player.y)/10
    -- buildingMarker: set size to building.width/10, building.height/10
    -- buildingMarker: set angle to building.angle
    
    for each enemy
    -- create enemyMarker at minimap.x +(enemy.x-player.x)/10, minimap.y + (enemy.y-player.y)/10
    -- enemyMarker: set size to enemy.width/10, enemy.height/10
    -- enemyMarker: set angle to enemy.angle
  • Sorry for all the trouble...but it worked after all, just like you said. I'm not sure where my issue was coming from when I tried it earlier. But it's all working now as I hoped for.

    Thank you for coming to my rescue once again. :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)