Jump to content

macklebee

Members
  • Posts

    3,946
  • Joined

  • Last visited

Posts posted by macklebee

  1. Best guess is that the color is not being set via whichever shader is being applied to them. What shader is being applied to it? Is it the latest version of inherent LE shaders or is it a custom shader?

  2. It is working for me.

    post-14-0-21314000-1483013353_thumb.jpg

     

    EDIT- This character does have a small scale applied to it (0.011,0.011,0.011) which in the past this would have caused numerous issues when parenting. But it looks like Josh changed the global parameter for the SetParent() command to only affect orientation instead of the child inheriting the parent's matrix (like it was done in LE2). I believe this is a recent change because i remember distinctly having scaling issues due to the parent's scaling this past year. Nope- still changes the scaling if the global parameter is set to false. The child's scale will be multiplied by the parent's scale. The information in the API Reference is incorrect as it implies only the rotation/position would be affected.

    • Upvote 1
  3. Just looking at your updated code, nothing is jumping out as the issue since you resolved the 'nil' variable. Would likely need to see the character itself to test. You do not by chance have either of these models (character or shield) scaled to something other than (1,1,1)? It would not be the first time I have seen parenting issues due to extreme scaling problems.

     

    --Edit: just tried your code in the first post with some small edits for removing the nil variable and loading my own models, and I noticed that the "shield" is getting loaded when the scene starts - not when you press the "Enter" key. Is that what you wanted?

     

    In any case, the above code in general works as I applied it to a crawler model with a cagelight as the shield attached to the left hand bone.

    post-14-0-58594300-1483012353_thumb.jpg

     

    My guess is that would need to see the models in question to determine the issue. Scaling is suspect.

  4. Without seeing the model in question to try myself, I am just going to guess that it has something to do with these two lines:

    self.leftHandShield = self.entity:FindChild("mixamorig:LeftHand")

    ...

    self.shields.shield1:SetParent(self.leftHandShield[0])

     

    The variable 'self.leftHandShield' is not equal to the 'self.leftHandShield[0]' variable. So it appears you are setting the parent to nil which would explain why it does not follow. For future reference, the '[#]' denotes an item in an arrayed/tabled variable.

     

    So just make the line this and it should work:

    self.shields.shield1:SetParent(self.leftHandShield)
    
  5. When you created your project, did you choose the FPS Template or did you choose the Blank Project? If you chose the Blank Project, it will not have the player prefab as its a blank project.

    post-14-0-80677000-1482815386.jpg

    If you create a new project and select the FPS template, then you will find the fps player prefab in the Assets folder location: 'Prefabs/player/FPSPlayer.pfb'

     

    EDIT -- another way to do it if you already have a fps template project but want the player prefab in the blank project, just copy the required files via windows explorer into the blank project.

     

     

    http://www.leadwerks.com/werkspace/page/tutorials/_/project-manager-r31#section1

    • Upvote 2
  6. If the hurt function is being driven by a collision then it probably is being added multiple times. A system print would determine this. But the code you are showing will mean the same effect would be added each time the Hurt function is called and the player health is below 50. You need to add a boolean check to see if the post effect has already been added and to prevent it from being added multiple times.

     

    if self.health<50 and self.postadded=="false" then

    self.camera:AddPostEffect("Shaders/PostEffects/radiation.shader")

    self.postadded = true

    end

     

    function Script:CameraFix()

    if self.health>50 and self.postadded=="true" then

    self.camera:RemovePostEffect(0)

    self.postadded = "false"

    end

    end

  7. Is that radiation post effect only being added once or is it being added multiple times when the player health is below 50? Just curious because the code above implies you are constantly adding the same effect to the camera effect stack.

     

    Not quite sure why CleatPostEffects() is causing the scene to bleed but you could try to use the RemovePostEffect() command. Assuming you are only adding this one post effect to the stack then you could remove it via its number in the stack.

    self.camera:RemovePostEffect(0)
    

     

    Looking at this now - it would be helpful if Josh gave us a way to count the number of post effects in the stack. Something like 'camera:CountPostEffects()'?

  8. The video you posted indicates it is the mouse, its drivers, the mouse settings in windows, or a combination of those. Quick google search shows numerous issues with windows 8 and high dpi mouse users across a wide variety of applications and games. Suggested fixes include updated drivers for the mouse, disable the display scaling on high DPI settings, turn off enhance pointer precision or mouse sensitivity, etc...

  9. Agree. Either applying the gradient or adding a radius will draw the rectangle incorrectly.

    window=Window:Create("example",0,0,600,400,window.Titlebar+window.Center)

    context=Context:Create(window,4)

    world=World:Create()

    camera = Camera:Create()

     

    while window:KeyDown(Key.Escape)==false do

    if window:Closed() then break end

    Time:Update()

    world:Update()

    world:Render()

     

    context:SetBlendMode(Blend.Alpha)

    context:SetColor(1,0,0,1,0)

    context:SetColor(1,1,0,1,1)

     

    context:DrawRect(100,100,400,200,0,5)

    context:SetGradientMode(true)

    context:SetBlendMode(Blend.Solid)

     

    context:Sync(true)

    end

    post-14-0-18163300-1481989965.jpg

     

    And if doing gradient only:

    post-14-0-70821600-1481989998.jpg

    • Upvote 1
  10. As a workaround is there a way to unlink a prefab? It works if the prefab is no longer an instanced prefab (when I do this via the editor it makes the spritesheet play. Can I do this via code?).

    If you change any of the properties, the editor will ask you if you want to unlink the prefab.

     

    --EDIT I ran into this before and it looks like the issue is the emitter's animation columns and rows are being set to 1 no matter what is set in the prefab. The way I have been able to get around this bug is by attaching a small script to the emitter that sets the columns and rows.

    function Script:Start()

    self.entity:SetAnimationColumns(6)

    self.entity:SetAnimationRows(6)

    end

    The below picture shows a emitter with the above script saved as a prefab and a emitter without the script saved as a prefab loaded into the scene.

    post-14-0-89607500-1481681450_thumb.jpg

  11. Also, just load the "loading font' once as well.

     

    font = context:GetFont()

    loadingFont = Font:Load("Fonts/arial.ttf",42)

    loadingText = "L O A D I N G . . ."

     

    function LoadingScreen()

    context:SetBlendMode(Blend.Alpha)

    context:SetFont(loadingFont)

    local x = (window:GetWidth() / 2) - (loadingFont:GetTextWidth(loadingText) / 2)

    local y = (window:GetHeight() / 2) - (loadingFont:GetHeight() / 2)

    -- Fill screen with black

    context:SetColor(0, 0, 0)

    context:DrawRect(0, 0, window:GetWidth(), window:GetHeight())

    -- Draw "Loading" text

    context:SetColor(1, 1, 1)

    context:DrawText(loadingText, x, y)

    context:SetFont(font)

    context:Sync(false)

    end

     

    LoadingScreen()

    When I do this and what I showed above for changing maps, I get the same memory usage each time I load the same map instead of it increasing each load.

     

    EDIT --Actually just load the font separately and one time like shown above and you can still keep the hook function in the Map:Load(). But since you are just drawing a static text/image there's no reason to do this as there is no reason to update per entity being loaded. If you were doing some kind of progress bar or dynamic text, then you would want to use the hook option.

    • Upvote 1
  12. A leak would imply its continually increasing. The problem is with what you are doing with the hook.

     

    hookname: script function name that will be called for each loaded entity in the scene.

     

    You are loading the font every time an entity is loaded from your map.

     

    Just call the loading screen function separately (and one time) if the map is changed then perform Map:Load().

     

    ... --in the main loops check for the changemapname

    ...

    LoadingScreen()

    if Map:Load("Maps/"..changemapname..".map")==false then return end

    ...

    ...

    • Upvote 1
  13.  

    Ah, thank you. Just tried it in standard C and it's not there yet that I could see (nor is it in the documentation yet, probably for that reason). But great to be reminded that it'll be part of the GUI functionality!

    That seems odd? For it to be available in lua typically means its in c++ version and ported to lua.

  14. We have it for Windows, why not Fonts? smile.png
    context->DrawText(text, x, y, Leadwerks::Font::CenterHorizontal | Leadwerks::Font::CenterVertical);

    Or maybe it would work with Contexts somehow.Absolutely the lowest priority but just a nice ease-of-life feature.

    er... i thought we had this already? does it not work?http://www.leadwerks.com/werkspace/blog/1/entry-1712-improved-2d-drawing-command-set/

     

    Edit-- It appears to be working at least in the beta

    window = Window:Create("example",0,0,600,400)

    context = Context:Create(window)

    world = World:Create()

    light = DirectionalLight:Create()

    light:SetRotation(45,45,0)

    camera = Camera:Create()

    camera:SetPosition(0,0,-3)

     

    box = Model:Box()

    box:SetColor(1,0.5,1,1)

     

    while not window:KeyHit(Key.Escape) do

    if window:Closed() then return false end

    box:Turn(0.5*Time:GetSpeed(),0.5*Time:GetSpeed(),0)

     

    Time:Update()

    world:Update()

    world:Render()

     

    context:SetBlendMode(Blend.Alpha)

    context:SetColor(1,0,0,.5)

    context:DrawRect(2,2,300,100)

    context:SetColor(1,0.5,0,.5)

    context:DrawRect(302,2,300,100)

    context:SetColor(1,1,1,1)

    context:DrawText(camera:GetPosition():ToString(),2,2,300,100,Text.Center)

    context:DrawText(camera:GetPosition():ToString(),302,2,300,100,Text.VCenter+Text.Center)

    context:SetBlendMode(Blend.Solid)

    context:Sync(true)

    end

    post-14-0-70590400-1480824944.jpg

    • Upvote 1
  15. It is probably still in your software library, so you can install it from there.

     

    To help with your eyesight and how I fixed the above issue:

    1) Changed software view to Grid

    2) Move Slider to max Zoom

    3) Right-clicked on software and chose 'Delete Local Content...'

    4) Re-installed

    post-14-0-09889100-1480623837.jpg

    post-14-0-16451600-1480623847.jpg

×
×
  • Create New...