-
Posts
4,816 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Posts posted by AggrorJorn
-
-
So you load the model, set the script, and mass and physics type are set. And your medkit falls down when you start the game?
If you run your game in debug mode and debug physics (I think you have to press P or F1) to toggle, does your entity have a physics shape? Does that differ from a medkit that is loaded via the editor?
-
And can you access the scripta variables? Is the collision type set? Is the mass set?
-
I mean the script you use to load in the medkit in to your scene. If you load the model of the medpack, you need to set the script yourself.Once you have spawned the medpack, can you access any variable in it? if not than that would mean there is no script attached to it.
-
Can you show the script? Are loading in the prefab or the model via script?
-
Note that the pickinfo object needs to be created before you do a pick.
local pickInfo = Pickinfo() if world:Pick( posPivote.x, posPivote.y, posPivote.z, posCamara.x, posCamara.y, posCamara.z, pickInfo, 0, true ) then System:Print(pickInfo.position) end
- 1
-
If you still want to use FlowGui, there is a small wiki: https://bitbucket.org/Aggror/flowgui/wiki/GUI Manager
here is how a minimal example would work:
- import flowGui somewhere in your main.lua
- create a flowGui manager
- create a gui element and add it to the manager. (styles are not even needed to get a ui element to work. )
Remember that FlowGui is no longer being developed and that is there is an official Leadwerks ui that has been released.
- 1
- 1
-
Pickmode 0 ignores picking. https://www.leadwerks.com/learn?page=API-Reference_Object_Entity_SetPickMode
- 1
-
You could also do a simple test to see which script is loaded first. Place this in the start function of the scripts you use.
System:Print("Script start from " .. self.entity:GetKeyValue("name"))
-
We are getting closer. So for some reason the Flowgui manager is empty in your script. Is it referenced in your countdown script?
Instead of linking in the flowGUI manager, you can also create it by script. Note that you only need 1 flowguiManager. So you would either place it in main.lua or you have to make sure it is made only once.
self.flowGUIManager = FlowGUI_Manager:Create(Window:GetCurrent(), Context:GetCurrent() )
-
"argument #3 is 'string';'[no object]'
means that you put in an object rather than a string. Can you post the code were you print info?
I tried with FlowGUI it's telling me "attempt to index field 'healthLabel' (a nil value) --line 93
Can you screenshot the scene tree were you have created the style, guimanager? Child/parent isn't really required but helps organising the scene. As long as the guimanager is loaded first and the styles are being loaded before you create the label, everything should work. If you look at any example scene from the FlowGUI project, you can see that I like to organise my scene as follow:
-
pivot-GuiManager (gui manager script attached)
-
pivot styles (no script attached)
- timerLabelStyle (labelstyle script attached)
-
pivot styles (no script attached)
-
mycustomobject (in your case the timer)
- Referencing GUI manager and Timer lablestyle.
here is loading the ui style with a wait time build in. I am not at home, so haven't tested it.
--Load FlowGUI if a script makes use of it. import "Scripts/FlowGUI/FlowGUI.lua" Script.guiManager = nil --entity "GUI manager" Script.healthLabelStyle = nil --entity "HealthLabelStyle" Script.healthLabel = nil Script.uiLoadInterval = 1 Script.startTimeStamp = nil Script.uiLoaded = false function Script:Start() self.startTimeStamp = Time:GetCurrent() self.guiManager = self.guiManager.script end function Script:UpdateWorld() if self.uiLoaded == false and Time:GetCurrent()-self.startTimeStamp > self.uiLoadInterval then self.healthLabelStyle = self.healthLabelStyle.script:GetStyle() self:CreateLabel() sel.uiLoaded = true end end function Script:CreateLabel() self.healthLabel = FG_Label:Create() self.healthLabel:SetPosition(Vec2(200,120)) self.healthLabel:SetScale(Vec2(150,50)) self.healthLabel:SetText("Your health") self.healthLabel:SetGUIStyle(self.healthLabelStyle) self.healthLabel:SetTextPosition(FG_TextPosition.Center) self.healthLabel:SetDebug(false) self.guiManager:AddElement(self.healthLabel) end function Script:PostRender() if sel.uiLoaded then self.healthLabel:SetText("Your updated health") end end
-
pivot-GuiManager (gui manager script attached)
-
You can load the font in the start function, and set the font in the postrender function.
self.font = Font:Load("Fonts/arial.ttf",10)
You can clean it up (like you already said) with something like this:
centerTimerX = context:GetWidth() - (timerAreaWidth / 2) drawX = centerTimerX - (font:GetTextWidth(text)/2)
You can also System:Print(font:GetTextWidth(text)) to see if the width of the text is actually changing.
Sorry I was thinking of a healthbar for some reason, but it doesn't matter for its purpose.
-
You can do a camera pick (so the pick starts from the camera point of view) https://www.leadwerks.com/learn?page=API-Reference_Object_Entity_Camera_Pick.
The pick returns true or false. when pick is true, you can also retrieve information from the pickinfo object. In this object you find the position of the pick, normal etc. https://www.leadwerks.com/learn?page=API-Reference_Object_PickInfo
- 1
-
Technically you would only have to recalculate the position if your health changes, but it can't hurt to do it every frame.
Context:GetWidth will get you the width of your game window.
GetTextWidth, will get get you the length of a text string. https://www.leadwerks.com/learn?page=API-Reference_Object_Asset_Font_GetTextWidthAlternatively with FlowGui.
Best to download the sample project and opening a sample scene with text element. From the top of my head
- create a pivot and attach flowgui manager lua script
- create a pivot and attach label style lua script (here you can fine tune font, text size, color, center positioning)
- create a healtbar script (your existing script) which references the label style and flowgui manager. Add something like this:
--Load FlowGUI if a script makes use of it. import "Scripts/FlowGUI/FlowGUI.lua" Script.guiManager = nil --entity "GUI manager" Script.healthLabelStyle = nil --entity "HealthLabelStyle" Script.healthLabel = nil function Script:UpdateWorld() self.healthLabelStyle = self.healthLabelStyle.script:GetStyle() self:CreateLabel() end function Script:CreateLabel() self.healthLabel = FG_Label:Create() self.healthLabel:SetPosition(Vec2(200,120)) self.healthLabel:SetScale(Vec2(150,50)) self.healthLabel:SetText("Your health") self.healthLabel:SetGUIStyle(self.healthLabelStyle) self.healthLabel:SetTextPosition(FG_TextPosition.Center) self.healthLabel:SetDebug(false) self.guiManager:AddElement(self.healthLabel) end function Script:PostRender() self.healthLabel:SetText("Your updated health") end
-
One thing you can do is for every monster:
- Get position of monster.
- use Camera:Unproject(monsterPosition) to get the 2d coordinates of the monster's 3d position
- Do a distance check from the monster2dCoordinates to the crossHaird2dCoordinates.
-
Ah I get it now. The best solution is not applying any 'move over' margin at all. Instead do the following:
- Lets say your health circle is 200 px wide.
- Get center position of the health UI: centerUiX = ScreenWidth - (healthCircleWidth/2)
- Get the healthAmountWidth of the text every frame. There is a leadwerks API command for that.
- Subtract half of the text width from the centerUiX: drawX = centerUiX - (healthAmountWidth/2)
- Draw the text with drawX;
You can also use FlowGUI (free for download at https://bitbucket.org/Aggror/flowgui/src). I don't know if the official leadwerks UI has text centering.
-
I am not really sure what you are trying to do. You are asking about centering text, but than demonstrate code that animates the text. Can you elaborate a little bit more.
-
You can use raycasting for this. This older video uses C++ but the idea is the same.
- 1
-
-
Verify integrity of game cache
- Restart your computer and relaunch Steam.
- Head over to the library section and right click on the game which is giving you problems.
- Click on its properties and select the local files.
- Click the “Verify Integrity of Game Cache” button and Steam will verify that game in a few minutes.
- Latest drivers?
- Verify if Visual Studio redistributable is installed. This can be found in the following folder: C:\Program Files (x86)\Steam\steamapps\common\\Leadwerks\_CommonRedist
-
Verify integrity of game cache
-
Try removing config file.
User/MyDocuments/Leadwerks/Leadwerks.cfg
-
Either adjust the pivot position in Blender or make the character model a child of the player and move it upwards. The physics controller remains on the parent.
-
That is looking really cool. Like gamecreator said, people tend to underestimate how much work goes in to this.
-
Very nice,
Will the sidebar return? I miss the recent blogs column.
- 1
-
Blogs page looks nice. Does it simply pick the first image you have in the blog?
-
- Access to the Leadwerks 5 alpha forum
- Early access to demo's, tests
- Join discussions on development
- You are listed as supporter in the bottom of the forum
- You get a different forum status:
Health bar FOV check
in Programming
Posted