Hello everyone, is possible to create a minimap of the scene in-game based on the player position? I tried a lot of solutions but they didn’t work as expected.
Hey @Alessio_Bonini, I came up with a method, but practice showed it was much harder to impliment than I originally thought! I used typescript since this boost preformance alot for code that runs constantly; Also it allows for pretending a group is an object which is very usefull in this example.
It’s not pretty, but it works suprisingly well. I added comments explaining the code, so hopefully it’s descriptive enough. But if you need any help, feel free to ask!
p.s. if you do have a question I recommend posting here instead of sending a personal message, so that it might help others too.
Thank you very much this is a very cool Project, it is possible to make all the red objects stay into the map, maybe deleting them before they completely exit from it?
Thank you Alessio, what exactly do you mean? Currently im making the red objects transparent if they exit the map, this is however calculated by their center point. Meaning up to half of the object will still appear outside of the green field as it moves out of it, and the object will dissapear once more than half of the object is outside of the green.
I was meaning that maybe it could be cool to make object disappeare when also a little piece of the object exit the green field but i think it will be better to create another field, bigger, behind the principal one to don’t make objects exits the fields.
Ah like that, It’s a bit thougher but I think best way to do that is making an invisable square the size of the map, keeping track of which items are currently colliding with it;
Then adding invisble rectangles on the border of the green square, giving each a “when colliding with another item” event,
with on enter:
“if ‘another item’ is part of the mapObjects then; set it’s opacity to 0%”
And on exit:
If ‘another item’ is part of the mapObjects and is colliding with the invisible square we made earlier then; set it’s opacity to 100%"
From the top of my head I think that should work.
The other option is to keep my current system (anything within certain range is visible), and have the borders I described, doing the collision check on those; setting the opacity of anything that intersects and is part of the mapObjects, to 0%.
Doing this after you’ve made everything within range visible allows the objects within the map to stay visible.
Not sure if this will cause artifacts though, because your setting the opacity of the objects on the edge of the map to 100% and then 0% in rapid succession.
I also think your solution is better though; My instinct was also to go for maybe like slightly thick black borders around the map to hide things popping in and out.
Ah also,if you want the objects inside of the map to be bigger/ smaller you can manually adjust the mapScale by adding a number instead of using the miniMap.scale; I just kept it that way for ease of use.
Hope this helps anyhow!
@Alessio_Bonini After a bit of fumbeling about I managed to get it to match the camera’s rotation. Feels much smoother and intuitive this way, I’ve updated the coSpace!
This is @Luc - well done!
Thank you very much techleapnz!
This is so cool! Thanks for creating an example, @Luc!