Jump to content

macklebee

Members
  • Posts

    3,946
  • Joined

  • Last visited

Posts posted by macklebee

  1. At the moment, I would say collision hulls are broken and probably have a lot to do with with the same thing that is happening here:

    A couple of things to note:

    - Your model can be picked up by setting the child mesh's mass to 1 but this breaks the physics and the collision hull will not move with it. (also requires the child mesh's gravity to be turned off)

    - Make sure you delete or at least don't export your modo directional light and camera when exporting the model (I don't think this is an issue but no reason to have these as children in the model)

     

    At the moment, I think would majority of people could get by with built in physics shapes being created, but if someone just has to have a custom shape before this issue gets fixed then:

    - Model custom shape (keeping in mind the origin of the actual model you are wanting to apply it towards).

    - Import in LE, view in asset browser, right-click and pick Generate Shape --> Polymesh or Convex Hull

    - Save the new PHY file as the same name as actual model that needs a custom physics shape

    - Place the actual model into scene and it will have your custom shape applied automatically.

    • Thanks 1
  2. with inherent lua:

    http://www.lua.org/manual/5.1/manual.html#5.6

    math.randomseed(Time:Millisecs()) 
    myvariable = math.random(min,max)

    with LE functions:

    https://www.leadwerks.com/learn?page=API-Reference_Object_Math_Random

    Math:SeedRandom(Time:Millisecs())
    myvariable = Math:Random(min,max)

    In both cases, you need to set the minimum and maximum values (min & max) that the random number should be equal to or fall between.

     

    Just FYI - there is a search available in the upper right-hand corner of the forum that can allow you to search for stuff like this :

    search.jpg.8e3e0a4118cd445aa2637dd10534d6c7.jpg

    • Haha 1
    • Upvote 1
  3. function Script:PostRender(context)
    	context:SetBlendMode(Blend.Alpha)
    	context:DrawImage(self.imgHudPlayer,context:GetWidth()-200, context:GetHeight()-200,200,200)
    	context:SetBlendMode(Blend.Solid)
    end

     

    • Like 1
  4. 11 minutes ago, Argent Arts said:

    Another thing I've noticed - If I bring in a model that ships with Leadwerks, like one of the crate models, I can select it freely in any of the viewports. When I select it, the model turns red to indicate it is selected. My test models cannot be selected in the viewport, but can be selected in the scene tree. However, once selected in the scene tree, they do not turn red in the viewport to indicate they are selected. Even so, the move gizmo handle appears, so I can still move the model and it moves just fine. 

    So, the model looks correct in all viewports, but I cannot select it and when selected in the scene tree, it does not turn red. I can still manipulate it (move, rotate, and scale) as long as I click+drag the gizmo handles. 

    Its the same thing already reported in the second bug report posted above. Until Josh re-releases the fix that was done for it in 4.6, this will be an issue.

    • Like 1
  5. Two things that I can see: 1) you are using the wrong blendmode and 2) not the textures I mentioned in the link. Also for the 100th time, if you do not post your files for us to try, we can only guess at what else you are doing wrong. Help us to help you.

  6. Again, I can't speak for what you have because I do not have it. If you are using the standard monster AI script on the crawler, then it should work correctly just like the test that I did above. If you are using your own custom scripts for the AI and whatever you currently have for the minimap, then nobody but you probably has that exact setup. Provide an example project that shows the issue and someone may be willing to help troubleshoot. 

  7. If the minimap you are referring to was the simple shader and script version I posted and then Aggror added a sphere to it to check for nearby enemies, then the problem could be that the sphere is being set as a child to the player. Twice for some reason? If i had to guess  what the problem was without testing it out, i would say its because the sphere is now a child of the player which the enemy AI script assumes the sphere is the player. The sphere is 50 meters in diameter.

    function Script:Start()
        self.miniMapSphere = Model:Sphere(8,self.player) -- by putting the player as the second parameter, you just set the sphere as a child to the player
        self.miniMapSphere:SetScale(50,50,50)
        self.miniMapSphere:SetPosition(self.player:GetPosition(true))
        
        --Parenting the sphere to the player, means we dont have to update the position ourselves again.
        self.miniMapSphere:SetParent(self.player) -- this is duplicating setting the parent?
        self.miniMapSphere:Hide()
    end

    so what you can try is to remove the parenting and then update the position of the sphere in the Script:UpdateWorld() function.

    function Script:Start()
        self.miniMapSphere = Model:Sphere(8)
        self.miniMapSphere:SetScale(50,50,50)
        self.miniMapSphere:SetPosition(self.player:GetPosition(true))
        self.miniMapSphere:Hide()
    end
    function Script:UpdateWorld()
        self.timer = self.timer + Time:GetSpeed()
    	self.miniMapSphere:SetPosition(self.player:GetPosition(true)) --add this to update the position of the sphere
        if self.timer > self.timeUntilMinimapUpdates then
            self.timer = 0
            self.enemyEntities = nil
            local AABB = self.miniMapSphere:GetAABB(1)
    
            --We pass along the entity that our current script is attached to
            world:ForEachEntityInAABBDo(AABB, "Callback", self.entity) 
        end
    end

    If the above is not the latest and greatest code you are working from, then my apologies. This is just a guess since i don't have an easy way to test it out, but it may be worth a try to see if it resolves your issue.

     

    --EDIT: I just tested my theory above by placing a crawler with the standard monster AI script into a simple terrain scene in the editor. I changed the visual range to 5 meters. i then placed a player prefab in the scene about 30 meters away. Then I created a 50-m diameter CSG sphere with the invisible material. Placed the sphere's center at the location of the player and dragged the sphere in the scene browser to be a child under the player. Started the game and once the player moves a couple of steps toward the crawler, and it immediately starts to chase me. So it looks like my theory may be correct.

  8. 5 minutes ago, Josh said:

    Lua sandboxing disables many libraries so that unsafe code cannot be run. By default it is disabled (and the warning given), and it will only be enabled if a command line parameter is passed to the EXE. This was implemented for Game Launcher, but probably isn't so important now.

    Eh actually its probably still important for users to understand that by having the sandbox disabled that it loads specific lua libraries that could be used to run unsafe code. Of course, it should be left up to the programmer to decide their needs, but without that option I do not think most people here would understand what was being enabled in the background. I personally like having the option.

    • Upvote 2
  9. 14 minutes ago, Josh said:

    What is a "normal" DrawText command?

    The normal would be just 'context:DrawText("text",x,y)'. This version of DrawText() is not affected by the creation of gui element. But if you use 'context:DrawText("text",x,y,w,h,style)' and have created a gui element, it will be hidden - unless of course you redraw the gui base as shown in my example. So for whatever reason, the two versions of DrawText() react differently depending on whether a gui element exists.

  10. I could be wrong but I believe the tabber is an illusion of sorts that requires the programmer to create the effect of changing tabs by showing and hiding the other gui elements depending on which tab is selected.

    EDITED -- Added panels to allow for grouping of gui elements to make showing and hiding for the different tabs easier.

    example:

    local window = Window:Create("tabber example",0,0,400,300,Window.Titlebar+Window.Center)
    local context = Context:Create(window)
    local gui = GUI:Create(context)
    
    tabber = Widget:Tabber(20,20,300,150,gui:GetBase())
    tabber:AddItem("Buildings1", true)
    tabber:AddItem("Buildings2",false)
    tabber:AddItem("Buildings3",false)
    
    panel0 = Widget:Panel(0,0,300,150,tabber)
    wbase = Widget:Button("Foundation",10,60,80,30,panel0)
    
    panel1 = Widget:Panel(0,0,300,150,tabber) 
    wwall = Widget:Button("Wall",100,60,80,30,panel1)
    checkbox = Widget:Button("Checkbox",10,60,76,26,panel1)
    checkbox:SetString("style","Checkbox")
    panel1:Hide()
    
    panel2 = Widget:Panel(0,0,300,150,tabber)
    wroof = Widget:Button("Roof",190,60,80,30,panel2)
    panel2:Hide()
    
    while not window:KeyHit(Key.Escape) do
    	if window:Closed() then return false end
            
    	while EventQueue:Peek() do
    		local event = EventQueue:Wait()
    		if event.source == tabber then 
    			if event.data == 0 then 
    				panel0:Show()
    				panel1:Hide()
    				panel2:Hide()
    			elseif event.data == 1 then
    				panel0:Hide()
    				panel1:Show()
    				panel2:Hide()
    			else
    				panel0:Hide()
    				panel1:Hide()
    				panel2:Show()
    			end
    		end
    	end
    	context:Sync()
    end

     

    tabber2.jpg

    • Like 2
    • Thanks 1
  11. This above is what was needed to be provided to help troubleshoot. An example that demonstrates the issue. So from the looks of it, anything that uses the undocumented, new DrawText() with the extended parameters for centering within a given rectangle does not play well not just with the gamemenu script but any gui element you create. As a test I created a simple program that created a label and then just performed the new DrawText() version that was not part of the label/gui. The new version of DrawText() if not part of the gui for some reason will be hidden. So what I found is if I just simply redraw the gui's base whether its hidden or not, the new DrawText() will show properly.

    Example:

    window = Window:Create("Label Example",0,0,800,600,Window.Titlebar + Window.Center)
    context = Context:Create(window)
    world = World:Create()
    camera = Camera:Create()
    camera:SetPosition(0,0,-3)
    light = DirectionalLight:Create()
    light:SetRotation(35,35,0)
    box = Model:Box()
    box:SetColor(1,0.5,0,1)
    
    gui = GUI:Create(context)
    base = gui:GetBase()
    base:SetScript("Scripts/GUI/panel.lua")
    base:SetObject("backgroundcolor",Vec4(0,0,0,0.5))
    
    colorlabel = Widget:Create("Example", 20, 20, 300, 80, base, "Scripts/GUI/Label.lua")
    colorlabel:SetString("align","Center")
    colorlabel:SetString("valign","Center")
    colorlabel:SetBool("border",true)
    
    gui:Hide()
    toggle = 0
    
    clip = 10
    Ammo = 100
    counter = 1400
    
    while not window:KeyHit(Key.Escape) do
    	if window:Closed() then return false end
        
    	box:Turn(Time:GetSpeed()*0.5,Time:GetSpeed()*0.3,0)
    	
    	if window:KeyHit(Key.Space) then
    		toggle = 1 - toggle
    		if toggle == 1 then 
    			gui:Show()
    		else
    			gui:Hide()
    		end
    	end
    	Time:Update()
    	world:Update()
    	world:Render()
    	
    	context:SetBlendMode(Blend.Alpha)
    	context:SetColor(1,0,0,.5)
    	context:DrawText(string.format("Ammo1: "..clip.. " | " ..Ammo), 100, 80)
    	context:DrawText("Press SPACE to toggle gui", 100, 300)
    	context:DrawText(counter,38,30,300,300,Text.VCenter+Text.Center)
    	context:SetBlendMode(Blend.Solid)
    	--base:Redraw()--uncomment this and you will draw the new DrawText() version above
        context:Sync()
    end

    So based on that little example, all we need to fix the OP issue is to redraw the gamemenu's gui base. So if you add the redraw code to Menu.lua, it will draw properly everything in Jazz's example. So in the GameMenu:Update() function in the Menu.lua script, before it returns true, add the following code to line 480:

    gui:GetBase():Redraw()

    Edit -- this is admittedly a work around, but a fairly simple fix for something that Josh might not ever get around to resolving with DrawText() - especially since this version of DrawText() isn't officially documented.

    Edit-- Or if you don't want to edit the Menu.lua script, then in the example Jazz provided, just add this before the context:Sync(true):

    gamemenu.gui:GetBase():Redraw()

    and everything appears to be drawn properly. This should also fix the problem the OP is having if he adds it to the default Main.lua as well.

    • Like 2
  12. Both of those work fine, even though there is no reason to use 'string.format()' in your example.

    example:

    window = Window:Create("example",0,0,400,400)
    context = Context:Create(window)
    world = World:Create()
    light = DirectionalLight:Create()
    light:SetRotation(45,45,0)
    camera = Camera:Create()
    camera:SetPosition(0,0,-3)
    
    counter = 1400
    toggle = 0
    myfont = Font:Load("Fonts/arial.ttf", 24)
    context:SetFont(myfont)
    
    clip = 10
    Ammo = 100
    
    while not window:KeyHit(Key.Escape) do
    	if window:Closed() then return false end
    
    	if toggle==1 then counter = counter + 10 end
    	if toggle==0 then counter = counter - 10 end
    	if counter>=1400 then toggle = 0 end
    	if counter<=10 then toggle = 1 end
    
    	Time:Update()
    	world:Update()
    	world:Render()
    
    	context:SetBlendMode(Blend.Alpha)
    	context:SetColor(1,0,0,.5)
    	context:DrawRect(38,30,300,300,1,30)
    	context:DrawText(string.format("%.0f",counter),38,30,300,300,Text.VCenter+Text.Center)
    	context:SetColor(1,1,1,1)
    	context:DrawText("Ammo: "..clip.. " | " ..Ammo, 20,108)
    	context:DrawText(string.format("Ammo: "..clip.. " | " ..Ammo), 20, 248, 300, 50, Text.VCenter+Text.Center)
    	context:SetBlendMode(Blend.Solid)
    	context:Sync(true)
    
    end

    At this point, you really need to provide something that we can try that replicates your issue. There is a reason no one has replied to your post - there's not enough information provided for anyone to do anything other than guess at what you are doing wrong. Actually provide a simple example that shows the problem that people can try and more than likely someone can help you.

    • Like 1
  13. Post something that will allow us to replicate the problem - the map, the project, the materials, etc. anything. Without an example to test, all we can do is guess at what the problem could be.

     

    Edit: Since you provided nothing to let us test, I would guess that your issue is that the light is being blocked by a model / player. The spotlight shown is not the standard flashlight image obtained from the standard player model and script. So are we to assume you are using your own player model and script with a custom light?

  14. Short answer: No. As it stands, the vegetation paint tool was meant for placement of thousands of static models not prefabs into a scene.

    Long answer: There may be things that could be done as a work around for what you want. Explain what these scripts you are wanting to attach to the trees and rocks would do.

    Example of affecting painted vegetation in a scene with a script from the old LE2 days:

     

    • Like 2
  15. The problem with using a CSG cylinder instead of a model is that its origin is at the center and not at the base (or the feet like with a character model). If you look at the SetInput() example, notice that the 'visiblecapsule' cylinder is set as a child to the pivot (which is the actual player) and the cylinder's center is positioned up 1 meter from the ground.

    • Thanks 2
  16. Ma-Shell obviously knows his vector math but like the OP, vector math has always been a struggle for me though I can handle 3D geometry fair enough . I have to break vector math down into steps that I can understand and follow, So even though you have an answer already (but past my ability to follow), I decided to take a crack at this. I used multiple references and I will post them with the steps as this was a fun learning experience for me.

    So the problem was to find pointD given this information:

    given.jpg.a40441537f1a5f5244aa33351cfb9c7f.jpg 

    Given: 

    • 3 points given are all on the same plane, points A, B, & C 
    • The angle between VectorA-B and VectorA-C is equal to angle between  VectorA-B and VectorA-D
    • The distance from point A to point D is known

    Find: point D 

    Assumptions:

    • The three given points are not collinear to allow for determining the plane equation
    • Due to equal angles between vectors, VectorA-MirroredPoint is the reflected vector of VectorA-C across the mirror plane that is along VectorA-B

     

    Solution:

    To reflect a point across the mirror plane, we must first find the plane that the three given points (A,B, and C) are located. Once we have planeABC, then the mirror plane will be orthogonal to that plane and pass through the line or vector AB. Once the mirror plane is determined, then we can mirror the point. And finally determine the point along the line where the fixed length would occur.

    1) Find the plane that contains points A, B, and C. Using the 3 points, you can calculate two vectors:

        1a) Find the two vectors given the 3 points - A, B, & C. --Finding a 3D line through 2 points --https://www.youtube.com/watch?v=JlRagTNGBF0
              Vab = FindVector( pointA, pointB ) --vector AB
              Vac = FindVector( pointA, pointC ) --vector AC

        1b) Get the normal vector to two vectors. --Equation of a Plane Passing Through 3 Points --https://www.youtube.com/watch?v=0qYJfKG-3l8                           

              normalvector = FindNormalOfTwoVectors( Vab, Vac )

        1c) Get the Plane Equation using the normal vector and a point --Note that you can use any of the 3 points above and get same answer.

              plane = GetPlaneEquation( normalvector, pointA )

    2) To find orthogonal plane for mirror/reflection, we need two vectors and point on the plane -Just like before!
         --Find the Equation of Plane Containing a Line and Orhtogonal to a Given Plane --https://www.youtube.com/watch?v=aupy5wwAyb8
        2a) The normal of planeABC is a vector on the Mirror plane

              Vn = FindNormalVectorOfPlane(plane) 

        2b) We want the mirror/reflection plane to also contain vector AB - which we have already found = Vab. Find the normal vector to the two vectors.

              Mirror_normalvector = FindNormalOfTwoVectors(Vn, Vab)

        2c) Now get the Mirrored Plane's Equation using pointA or pointB and its normal vector

              Mirror_plane = GetPlaneEquation(Mirror_normalvector, pointA)

    3) Now that we have the reflection plane that that runs through line AB, lets mirror pointC about it

       --Find Mirror Image of a Point Reflected on Vector Plane
       --https://www.youtube.com/watch?v=fvXG-DVx6z0

         pointMP = FindMirroredPoint(Mirror_plane, pointC)

    4) Find pointD that is Dist_AD from pointA

       --Finding a point along a line in 3D given 2 points
       --Used alternative method shown at bottom of page
       --https://math.stackexchange.com/questions/83404/finding-a-point-along-a-line-in-three-dimensions-given-two-points

         pointD = FindPointAlongLine(pointA, pointMP, Dist_AD)

     

    Scripts:

     

    • Like 1
    • Thanks 1
×
×
  • Create New...