Jump to content

X54321

Members
  • Posts

    40
  • Joined

  • Last visited

Posts posted by X54321

  1. And you are sure that in PostRender() self.font is not nil? I just want to make sure you didn't just check it in Start() after it was loaded. Also check it in PostRender() before it renders it. That might at least help figure something out. My guess would be it has to be nil in PostRender() to crash the engine.

     

    Yes, I have already stated it isn't nil. I did both of the things you mentioned, and it was not nil.

  2. I'M BACK! I'm trying to load a special font for the health percentage in my game; Loading the font goes by smoothly, but when I actually try to set the font it crashes. I know the font isn't nil (I tested it) and it can't be the font I'm using because it's the default font, except with a different size. Anyways, here's some code:

     

    local window = Window:GetCurrent()
    local forward = 0
    local strafe = 0
    local angle = 0
    local firing = false
    local shootTimer = 0
    local health = 100
    local pickInfo = PickInfo()
    
    function Script:Start()
    self.w1 = Texture:Load("Materials/HUD/gun_overlay.tex")
    self.w1f = Texture:Load("Materials/HUD/gun_overlay_02.tex")
    self.ch = Texture:Load("Materials/HUD/crosshair.tex")
    self.hb = Texture:Load("Materials/HUD/healthbar.tex")
    self.entity:SetKeyValue("weapon", "blaster")
    self.entity:SetKeyValue("type", "player")
    self.font = Font:Load("Materials/Fonts/arial.ttf",36)
    
    local material = Material:Create()
    material:SetBlendMode(5)
    self.entity:SetMaterial(material)
    material:Release()
    end
    function Script:UpdateWorld()
    window = Window:GetCurrent()
    angle = angle - dx * 0.25
    local jump = 0
    if window:KeyDown(Key.Space) and self.entity:GetAirborne() == false then
     jump = 10
    end
    if window:MouseHit(1) and firing == false and self.entity:GetKeyValue("weapon") ~= "none" then
     firing = true
    
     local p0 = self.entity:GetChild(0):GetPosition(true)
     local p1 = Transform:Point(0,0,20,self.entity:GetChild(0),nil)
    
     self.entity.world:Pick(p0,p1, pickInfo, 0, true)
     if pickInfo.entity ~= nil then
      if pickInfo.entity:GetKeyValue("type") == "enemy" then
       pickInfo.entity:SetKeyValue("hurt", "true")
      end
     end
    
    end
    if firing == true and shootTimer < 24 then
     shootTimer = shootTimer + 1
    elseif firing == true and shootTimer == 24 then
     shootTimer = 0
     firing = false
    end
    forward = (window:KeyDown(Key.W) and 1 or 0)*6 - (window:KeyDown(Key.S) and 1 or 0) * 6
    strafe = (window:KeyDown(Key.D) and 1 or 0)*6 - (window:KeyDown(Key.A) and 1 or 0) * 6
    self.entity:SetInput(angle, forward, strafe, jump, false)
    onGround = false
    end
    function Script:PostRender(context)
    context:SetBlendMode(Blend.Alpha)
    context:SetColor(1,1,1,1)
    context:DrawImage(self.ch, 400 - 16, 300 - 16)
    --context:DrawImage(self.hb, 0, 600 - 104)
    context:SetFont(self.font)
    context:DrawText("Health: "..health.."%", 160, 600 - 72)
    end
    

  3. I'm trying to draw a weapon overlay for my game; I already have the texture for it imported and in the right place, but whenever I actually draw it the game crashes. No errors, nothing. The .tex settings for it is the default except all checkboxes are unchecked and the filter mode is set to 'pixel'.

     

    Here's the part where I draw the image:

     

    local window = Window:GetCurrent()
    local forward = 0
    local strafe = 0
    local angle = 0
    local weapon = 0
    function Script:Create()
    self.w1 = Texture:Load("Materials/HUD/gun_overlay.tex")
    end
    function Script:UpdateWorld()
    window = Window:GetCurrent()
    angle = angle - dx * 0.25
    forward = (window:KeyDown(Key.W) and 1 or 0)*6 - (window:KeyDown(Key.S) and 1 or 0) * 6
    strafe = (window:KeyDown(Key.D) and 1 or 0)*6 - (window:KeyDown(Key.A) and 1 or 0) * 6
    self.entity:SetInput(angle, forward, strafe, 0, false)
    end
    function Script:EquipBlaster()--in
    weapon = 1
    end
    function Script:PostRender(context)
    context:SetBlendMode(Blend.Alpha)
    context:SetColor(1,1,1,1)
    if weapon == 1 then
    context:DrawImage(self.w1, 52, 52)
    end
    end
    

  4. Ok, so it turns out that method had a lot of collision bugs. I then came up with a new solution that uses the physics, and it (almost) works, but it is really weird. The physics for the player are so jittery it makes the game virtually unplayable. I don't think it's lag, either, because the frame rate is about 180! I'll put up the project in a moment; It'll take a while to upload.

  5. ANSWERED

     

    Hi, I just bought this engine a couple of days ago. It's really nice so far, but the physics engine is kind of glitchy. There have been other posts on the physics engine, and so I am aware the developer is working on it. BUT, the game I am looking to make doesn't need any sort of physics; I just need collision. Unfortunately, I can't seem to collide with anything if the mass is set to 0. If I enable physics, I can't seem to get it to not move, and It goes through everything. SO, does anyone have an idea?

     

    *EDIT: I am using a rigid body character, not a character controller.

×
×
  • Create New...