Yue Posted January 23, 2022 Share Posted January 23, 2022 I want to have some clue how to create a mini map in Leadwerks that marks the position on the ground of the player and some targets. Someone who's experience can point me in the right direction please. Quote Link to comment Share on other sites More sharing options...
havenphillip Posted January 23, 2022 Share Posted January 23, 2022 There's one if you look up "HUD Elements" in the Workshop that I got from Macklebee. You could probably chop that one up and make it work for you. The minimap script creates a bounding sphere around the player and looks for the KeyValue "enemy." So you have to add SetKeyValue to "enemy" in your target script. I think I included a crawler script that has that added in the Start function. 1 Quote Link to comment Share on other sites More sharing options...
Yue Posted January 23, 2022 Author Share Posted January 23, 2022 I was looking at the script, however I see commands called Buffer and strange things that are not documented. My question is, using SetRenderTarget is equivalent to the same thing? At this point it is rendering what a camera sees in a texture or material. Quote Link to comment Share on other sites More sharing options...
havenphillip Posted January 24, 2022 Share Posted January 24, 2022 Yeah the buffer is just a target to render to. All it's doing is double-buffering the scene. In the updateworld function you can see it's toggling between the two, and what occurs on the screen is bound to the buffer using Bind(). I think those were the important parts. I messed with this CCTV script from here at one point http://leadwerks.wikidot.com/start - which is kind of similar - but it never went anywhere. If I recall correctly the trouble I had was figuring out how to use the CCTV in the PostRender function. 1 Quote Link to comment Share on other sites More sharing options...
Yue Posted January 24, 2022 Author Share Posted January 24, 2022 My tests seem to fit what I need, but the drawback is that the camera that follows the character always has to look at the cube that renders the material with that texture so that it is updating the texture where the mini map is displayed. Any suggestions? Quote Link to comment Share on other sites More sharing options...
Yue Posted January 24, 2022 Author Share Posted January 24, 2022 Ok, Solved Here. 1 Quote Link to comment Share on other sites More sharing options...
havenphillip Posted January 25, 2022 Share Posted January 25, 2022 That's cool. What script idea did you go with in the end? 1 Quote Link to comment Share on other sites More sharing options...
Yue Posted January 25, 2022 Author Share Posted January 25, 2022 15 minutes ago, havenphillip said: That's cool. What script idea did you go with in the end? What I did was to try to understand the system and create my own script, so I can learn a little bit about the subject. This is only a prototype. --################################################## --# Proytecto : Astrocuco --# Scripter : Yue Rexie. --# Sitio Web : https://www.iris3dgames.xyz --# Fichero : Hud.lua --################################################## --# Notas : Script enganchado a la entidad --# MiniMap. --################################################ Script.map = nil --entity "Map Mesh" function Script:Start() self.entity:SetProjectionMode(Camera.Orthographic) self.texture = Texture:Create(256,256) self.mtl = Material:Create() self.mtl:SetShader("Shaders/Model/Diffuse.shader") self.mtl:SetTexture(self.texture) --self.mtl:SetColor(1,0,0) self.map:SetMaterial(self.mtl) self.entity:SetRenderTarget(self.texture) self.map:SetParent(World:GetCurrent():FindEntity("CameraPlayer"),true) self.map:SetPosition(-1,0,1,false) --self.entity:SetZoom(250) self.entity:SetFOV(45) end function Script:UpdateWorld() self.posPlayer = player:GetPosition(true) self.rotPlayer = World:GetCurrent():FindEntity("CameraPlayer"):GetRotation(true) self.entity:SetPosition(self.posPlayer.x, self.posPlayer.y+40, self.posPlayer.z, true) self.entity:SetRotation(90,self.rotPlayer.y,0,false) end function Script:PostRender(context) context:DrawImage(self.texture,0,context:GetHeight()-128,128,128 ) end 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.