Jump to content

thehankinator

Members
  • Posts

    436
  • Joined

  • Last visited

Posts posted by thehankinator

  1. Sorry, posted the backup script by accident.This is the real one that I have been using (The Example one).

    Is that whole thing in your Main.lua? If so, you've got the pause screen script combined with the Main.lua script. The second portion (starting with the second "import" line to the end) should go in it's own script and be assigned to a pivot in your level.

  2. I've been thinking about this for my UI library. It's an awkward problem that I've not found a perfect solution for but this might work for your use case.The following function will determine a font height so that it will fit in a box defined by w and h. It will start with the font at max size, if the text goes beyond the defined width, it will reduce the font size to fit.

     

    It loads a font every time you call it so I would call it only when text changes.

     

    function FontFit(fontpath, text, w, h)
    local font = Font:Load(fontpath, h)
    
    textwidth = font:GetTextWidth(text)
    font:Release()
    if textwidth > w then
     return h * (w / textwidth)
    else
     return h
    end
    end
    

     

    An example of loading a font that will fit some_text that will fit in an area of 100x30

    local FontHeight = FontFit("Fonts/arial.ttf", some_text, 100, 30)
    local font = Font:Load("Fonts/arial.ttf", FontHeight)
    

    • Upvote 1
  3. I'm just not sure where I am going wrong, I have tried to replace the normal main.lua with the example one. I also have tried following the instructions on this page in an attempt to try and make a simple GUI Menu. When I press the esc key, nothing happens. Any help?

     

    Would you post the code for your menu? I'll take a look.

  4. Your textures have details that clash with your geometry. You should use either neutral textures on those beams or have some interplay between your level geometry and textures. See Dexsoft's texture packs for examples of this:

    post-1-0-92949800-1463122169.jpg

     

    Or my own design, using a combination of CSG and some detail props. Notice that my design still flows from the textures:

    post-1-0-23073300-1463122290.jpg

    This might be a dumb question but how do you determine if a texture clashes with the geometry?

  5. this seems to work ok - at least better than what the code above is showing for the player angle which for some reason is never close to the set angle:

    angle = 0 --defined before main loop

    ...

    ...

    p_rot = player:GetRotation(true)

    if window:KeyHit(Key.Right) then angle = 270 end

    if window:KeyHit(Key.Left) then angle = 90 end

    finalangle = Math:CurveAngle(angle, p_rot.y, 1.05)--setting division parameter to 1 or lower results in weird angles

    player:SetInput(finalangle, 0, 0, 0, false, 1, 0.5, false, 0.0)

     

    Other than that, I could only suggest you stick with a rigid body physics player and move/rotate using SetPosition/SetRotation.

     

    I noticed my example used -90 and yours used 270 so I tried mine with 90/270 but still no luck.

     

    If I understand the update to SetInput correctly, I shouldn't need to play games with interpolating the angle to get the rotation to work. According to the updated reference for SetInput, setting maxrotationspeed to 0 should result in an instantaneous change to the requested angle. I might be misunderstanding the documentation but I think that my script should work.

     

    I'd love to use rigid body physics with SetRotation but then I'd have to implement my own pathing algorithm which seems like a lot of added work and complication when all that functionality already exists in LE it's just this one part that doesn't work and I think should.

  6. I am having trouble getting the instantaneous change working. I've updated my original script (below) to set the new flags. Unfortunately I am not getting the instantaneous change I was expecting. I used default for everything except maxrotationspeed, I set it to 0. I also tried setting maxrotationspeed to 360 as well as detailed to true but that didn't help either. Did I misunderstand how to use this change? I am opt into beta.

     

    --Create a window
    window = Window:Create()
    context = Context:Create(window)
    
    world = World:Create()
    local camera = Camera:Create()
    camera:SetRotation(35,0,0)
    camera:Move(0,0,-8)
    
    local light = DirectionalLight:Create()
    light:SetRotation(35,35,0)
    
    --Enable navmesh debugging
    camera:SetDebugNavigationMode(true)
    
    --Create the ground
    local ground = Model:Box(10,1,10)
    ground:SetPosition(0,-0.5,0)
    ground:SetColor(0.0,0.25,0.0)
    
    --Create a shape
    local shape = Shape:Box(0,0,0, 0,0,0, 10,1,10)
    ground:SetShape(shape)
    shape:Release()
    
    --Enable navigation obstacles
    ground:SetNavigationMode(true)
    
    --Create a character
    player = Pivot:Create()
    local visiblecapsule = Model:Cone(16, player)
    visiblecapsule:SetScale(1,2,1)
    visiblecapsule:SetPosition(0,1,0)
    visiblecapsule:SetRotation(90, 0 ,0)
    player:SetPosition(0,0,0)
    player:SetMass(1)
    player:SetPhysicsMode(Entity.CharacterPhysics)
    
    while not window:KeyHit(Key.Escape) do
       if window:Closed() then return false end
    
       Time:Update()
    
       if window:KeyHit(Key.Right) then
           player:SetInput(-90, 0, 0, 0, false, 1, 0.5, false, 0)
       end
    
       if window:KeyHit(Key.Left) then
           player:SetInput(90, 0, 0, 0, false, 1, 0.5, false, 0)
       end
    
       if window:KeyHit(Key.P) then
           System:Print(player:GetRotation(true).y)
       end
    
       world:Update()
       world:Render()
       context:Sync()
    end
    

×
×
  • Create New...