Search the Community
Showing results for tags 'Game Mechanics'.
Found 2 results
Hi community, I would like to talk about how to create a minimap. I made myself some thoughts latley how to realise a minimap. And I would like to collect some useful toughts here. I actually found a solution, so tell me what you think of it. It currently just works as a normal map, not as a minimap... Maybe it is very complicated what I do but thats why I created this post. Ok so I will start explaining. First of all I took a screenshot from the topview of my map. Out of this I made a simple Map, by exporting the shot to gimp or something similar. The important thing is that the map has the same propotions than the real map size. The main idea is to grab the players 3D Position and convert it to a 2D position fitting to the map size and displaying a rect at the converted 2D Position. The conversion works like this: I tell my script the real map size (you can find it out in the viewports) and the pixel size of my map. Because my map and the real map size are propotional, I can calculate a "minimap multiplier" by doing this calculation: real map size X / map size X = multiplier. Thats the first part of the puzzle I need. Second I would like to know where to draw the player start position on the minimap. Because I have nothing I can relate to, I create a "minimap origin" pivot in the scene setting it to the zero-point of our map (not the origin of the viewport!!). To convert the player start position to a 2D Vector we do the following trick explained by this code: self.playerPos = self.entity:GetPosition() local myPos = self.mapOrigin:GetPosition() self.mapOrigin:SetPosition(myPos.x, self.playerPos.y, self.playerPos.z) self.playerStartPos.x = self.mapOrigin:GetDistance(self.entity:GetParent()) self.mapOrigin:SetPosition(self.playerPos.x, self.playerPos.y, myPos.z) self.playerStartPos.y = self.mapOrigin:GetDistance(self.entity:GetParent()) self.mapOrigin:SetPosition(myPos) As you can see I move the map Origin to get the correct X and Y values for the needed 2D Vector. If you didnt forget to also tell the script where the map origin of the 2D Map is in screen space, then you can now draw the player start position correctly on your map. To calculate the movement of the player, better said his current position I do the following: self.playerOffset = Vec2((playerStartPos.x - currentPlayerPos.x) * self.minimapMultiplier, (currentPlayerPos.z - playerStartPos.z) * self.minimapMultiplier) Now you can correctly draw a rect on your map on the correct player position: local minimapOriginX = context:GetWidth() * 0.5 - (self.mapSize.x / 2) + 50 local minimapOriginY = context:GetHeight() * 0.5 + (self.mapSize.y / 2) - 10 local playerX = (minimapOriginX + (playerStartPos.x * self.minimapMultiplier) + self.playerOffset.x) local playerY = (minimapOriginY - (playerStartPos.y * self.minimapMultiplier) + self.playerOffset.y) context:SetColor(Vec4(0,0,0,255)) context:DrawRect(playerX, playerY, 10, 10) Tell me what you think of this method? If you have ideas how to improve my script just let me know. After I was recieving some help from the community I wanted to give something back. However I you think this is a very bad solution, I would be glad to know what other methods there are, I am just an amateur coder
Ok, so the purpose of this forum thread to to get some general help with any type of mechanic a user with bad programming skills might need for their game, think of it as an add-on to the tutorials I myself have been having a bit of trouble with a couple of things. As you might know I'm in the process of making a game called "A Demon's Game", it's a horror game so it needs some mechanics that I myself haven't been really able to work out that well which are... 1)Battery system, seriously, I have been battling this for the longest time and I can't figure out a good way to make a system whereas the user has a bar, or a countdown number that indicates how many seconds the flashlight has left, then it shuts off and can't be turned on untill another battery is picked up. Any help with this would be amazing. 2)Leaning/peeking, this one shoulnd't be too hard to make, all it is is camera manipulation whenever the user presses Q or E. But alas, I'm too dumb to figure out this for myself 3)Sneaking, yea, this one is a though one, imagine sneaking from thief or dishonored but in a more simple way, whereas the player crouches and the monster's visibility is lowered or something that would do the same effect. 4)Something that is really simple, if you've played vectronic, you would notice the reticle when you're playing looks like these 2 lines that used to form a square but with a slice down the middle, I would like to make something similar to that, a reticle, maybe even have it change depending on what the player was looking at, for example if the player looked at a note, the reticle would change to a magnifiying glass and when the player looked around normally it would go back to the default one. Sorry if I seem a bit hopeless with this post, but programming is the only thing that I'm not good at, so I would greatly appreciate some help! Cheers!