Jump to content

Braqoon

Members
  • Posts

    69
  • Joined

  • Last visited

Posts posted by Braqoon

  1. I only took a brief look at this, but I noticed some things that could be the problem.

    1. Collision.Projectile only collides with scene and prop

    2. bullet.position + travel... A Vec3 + float doesn't get the forward direction as far as I know.

    I may be wrong, but these are some suggestions.

     

    1. This is set correctly. Bullet does hit and collision get's triggered, but like I have mentioned only when sprite hit's vertex on collision mesh of the target.

    2.

    bullet.position = bullet.position+Vec3(0,0,travel)
    

    That works no problem. This is done after collision check and it's needed to move the bullet forward.

  2. So I have bullets which are sprites. Bullets are fired from a ship towards enemies and when bullet triggers a collision, enemy will get damaged or destroyed. That all works in principle but only when sprite will collide with vertex on collision mesh of the enemy. That results very often that bullet goes trough the object and don't trigger a collision.

     

    My bullet creation script:

    function Script:GetBullet(position)
    local bullet = Sprite:Create()
    bullet:SetPosition(Vec3(position.x,position.y,position.z+3))
    --bullet:SetPosition(position)
    bullet:SetViewMode(2)
    bullet:SetMass(0)
    bullet:SetGravityMode(false)
    bullet.origin = Vec3(position.x,position.y,position.z)
    local mat = Material:Load("Materials/Bullets/bullet1.mat")
    if mat then
    bullet:SetMaterial(mat)
    mat:Release()
    end
    return bullet
    end
    

     

    And my collision detection:

    function Script:UpdateWorld()
    local bullet,n,dist
    local pickinfo=PickInfo()
    local travel
    local bspeed=25
    local window = Window:GetCurrent()
    for n,bullet in ipairs(self.bullets) do
    
    travel = bspeed/60.0*Time:GetSpeed()
    
    if self.entity.world:Pick(bullet.position,bullet.position+travel,pickinfo,0,true,Collision.Projectile) then
    local enemy = self:FindScriptedParent(pickinfo.entity,"Hurt")
    table.remove(self.bullets,n)
    bullet:Release()
    bullet=nil
    if enemy~=nil then
     if enemy.script.health>0 then
     enemy.script:Hurt(self.bulletdamage,self.player)
     end
    end
    else
    if bullet ~=nill then
     dist = (bullet.position-bullet.origin):Length()
    travel = bspeed/60.0*Time:GetSpeed()
    bullet.position = bullet.position+Vec3(0,0,travel)
    bullet:SetPosition(bullet.position)
    
    if dist>self.bulletrange then
    table.remove(self.bullets,n)
    bullet:Release()
    bullet=nil
    end
    end
    end
    end
    

     

    This is largely based on FPSGun.lua

    Am I missing something ? I'm 99% sure that my sprite bullets only trigger a collision with collision hull vertexes which renders whole idea of using sprites as bullets not usable. Don't think that creating collision hull with big number of vertexes is a good solution.Even Convex Hull type mesh is not 'accurate' enough. Is there a way can I check if bullet is 'inside' of the other object which will trigger a collision ?

     

    Thanks

  3. Will player will be always in the vehicle ? If so, you need to build control for vehicle as your vehicle will be your player. Applies as well if you want to use vehicle as transport for your FPS player. You just need to find out how to switch what you control.

    • Upvote 1
  4. Hi,

     

    How one will go about passing variables between maps?

    For eg. let's take Marble Game. When player reaches trigger to load another map, game map loads from start and you play again, your score is zeroed. What if you want to pass a highscore or some other vars so I can access them in the new map? Should I store those vars globally so they are accessible regardless of what map is loaded ? How do I go about it ?

     

    Thanks.

  5. I have make it work with self.entity.world:Pick(), re-sued from bullet.lua

     

    function Script:UpdateWorld()
    local bullet,n,dist
    local pickinfo=PickInfo()
    local travel
    local bspeed=25
    local window = Window:GetCurrent()
    for n,bullet in ipairs(self.bullets) do
    
    travel = bspeed/60.0*Time:GetSpeed()
    
    if self.entity.world:Pick(bullet.position,bullet.position+travel,pickinfo,0,true,Collision.Projectile) then
    local enemy = self:FindScriptedParent(pickinfo.entity,"Hurt")
    table.remove(self.bullets,n)
    bullet:Release()
    bullet=nil
    if enemy~=nil then
     if enemy.script.health>0 then
     enemy.script:Hurt(self.bulletdamage,self.player)
     end
    end
    else
    if bullet ~=nill then
     dist = (bullet.position-bullet.origin):Length()
    travel = bspeed/60.0*Time:GetSpeed()
    bullet.position = bullet.position+Vec3(0,0,travel)
    bullet:SetPosition(bullet.position)
    
    if dist>self.bulletrange then
    table.remove(self.bullets,n)
    bullet:Release()
    bullet=nil
    end
    end
    end
    end
    if window:KeyDown(Key.E) then
    local currenttime=Time:GetCurrent()
    if self.lastfiretime==nil then self.lastfiretime=0 end
    if currenttime-self.lastfiretime>self.refirerate then
    self.lastfiretime = currenttime
    local pos = self.entity:GetPosition(true)
    table.insert(self.bullets,self:GetBullet(pos))
    end
    end
    

     

    To be honest I'm not 100% how this works but it does, this Pick function :)

    • Upvote 1
  6. Yes, thought about it but this made no difference. Hide for me only hides object from rendering. Other test is that I can trigger a collision with bullet so my player does not touch it. Enemy is hidden but then it stays on the scene and player can hit it. Anyway Release works as it should so not a big problem for now.

    • Upvote 2
  7. Hi, I'm not sure do I miss something obvious but for me self.entity:Hide() does not work as intended.

     

    Below I got a very simple enemy LUA script, which should on collision be 'removed' from gameplay.

    Object on collision does get hidden and not being rendered but it's still there and all the physics apply.

     

    According to http://www.leadwerks.com/werkspace/page/api-reference/_/entity/entityhide-r181 this should not be the case.

     

    function Script:Start()
    self.entity:SetMass(1)
    self.entity:SetGravityMode(false)
    self.entity:SetFriction(0,0)
    self.entity:SetCollisionType(Collision.Prop)
    self.health=50
    self.points= 100
    self.endof = 0
    end
    function Script:Collision(entity)
    self:Hurt(100)
    end
    function Script:Hurt(damage)
    if self.health > 0 then
    self.health = self.health - damage
    if self.health<= 0 then
    self.entity:Hide()
    self.entity:SetMass(0)
    self.entity:SetCollisionType(0)
    PlayerScore=PlayerScore+self.points
    
    end
    end
    end
    
    function Script:UpdatePhysics()
    --Get the game window
    local window = Window:GetCurrent()
    local evel = Vec3(0,0,-5)
    self.entity:SetVelocity(evel)
    end
    

     

    Can somebody explain ? Just to be clear Hurt is triggered on it's own when bullet hits the enemy with this script attached to it where collision is with player's model (currently a box). Regardless of collision with the player or hit by the bullet, self.entity:Hide() just stops rendering the object on the screen but it's still there and after respawn (respawn not reload) I can hit it again when enemy is hidden.

  8. Where ever your "Hurt" function is, put in:

     

    if self.health <= 0 then return end

     

    at the top. That will stop Respawn() from being called multiple times

     

    Hi,

     

    Running out of health is not a problem but lives is. At the moment if lives is <= 0 then it will not respawn. I have not done game over screen yet but that's only showing that live counter is to blame here as counter is being constantly altered as if one respawn cycle has not finished and another is already started.

     

    if self.health <= 0 then
    self.altitude = -1
    
    -- Which then will contribure overall to:
    
    function Script:UpdatePhysics()
    [...]
    self.vel = Vec3(self.pos,self.altitude,self.speed)
    
    -- and by altering altitude (falling), object (player) will hit TriggerPain and invoke restart in :
    
    function Script:TakeDamage(damage)
    self.health = self.health - damage
    if self.health<=0 then
    self:Respawn()
    end
    end
    
    -- Just to remind TriggerPain.lua
    --[[
    This script will act as a trigger to change the current map.
    Place this at the end of your map to make the player progress
    to the next level.
    ]]--
    Script.damage=1000--int "Damage"
    Script.enabled=true--bool "Enabled"
    
    function Script:Collision(entity, position, normal, speed)
    if self.enabled then
    if entity.script then
    if type(entity.script.TakeDamage)=="function" then
    entity.script:TakeDamage(self.damage)
    end
    end
    end
    end
    
    function Script:Enable()--in
    if self.enabled==false then
    self.enabled=true
    self:CallOutputs("Enable")
    end
    end
    
    function Script:Disable()--in
    if self.enabled then
    self.enabled=false
    self:CallOutputs("Disable")
    end
    end
    

     

    Now I might be wrong but on TakeDamage function must call Respawn or (yet to complete) Game Over screen, but for ever reason it does not do Respawn properly only when lives counter is in place. If number of lives is not being taken to account, Respawn works as it should.

  9. Hi, so I got this problem that I'm not sure how to resolve.

     

    I'm trying to add lives counter in my little test but seems like respawn is not quick enough and instead of removing one life it goes crazy and removes a lot more.

     

    I have took a respawn function from marble game tutorial with some modifications:

     

    function Script:Respawn()
    self.lives = self.lives - 1
     if self.lives > 0 then
    self.death = 0
    self.health=100
    self.altitude = 0
    self.entity:SetPosition(self.startposition)
    self.entity:SetRotation(0,0,0)
    self.entity:SetVelocity(Vec3(0,0,0))
    self.entity:SetOmega(Vec3(0,0,0))
    self.gamestarttime = Time:GetCurrent()+2000
     end
    end
    

     

    A bit of explanation:

     

    So I got a 'player' which is a just a box at the moment which is floating and if it will hit an obstacle then it starts to fall (hence self.altitude). Eventually it will hit a TriggerPain object and that will initiate respawn.

     

    Now if I remove from above code

    self.lives = self.lives - 1

     

    and run the game, all is fine. 'player' hits the TriggerPain, Respawn function resets the 'player' and all is OK.

     

    If self.lives is there and Respawn function is called, life is being deducted but game is not quick enough to reset players position and TriggerPain is being active again so Respawn goes again and another life is being deducted (or more). I have got lives counter rendered on the screen so I'm quite sure that is the problem.

     

    Question here is that how can I make it so Respawn allows to deduct a life and resets position properly? Not sure how to tackle it.

  10. It's possible but up to authors of the engine. I assume current Steam integration is only to provide DRM solution. Software published via Steam can be nor is enforced by Steam to be completely not integrated with Steam API. As in games this makes very little sense to do it due to lost of features like steam controller, achievements, etc. I hardly believe that LE users are after those 3 achievements.

     

    You can even have both of both worlds, if needed a config can be setup to bypass Steam initialization to make LE standalone, but again i think authors of LE like the DRM that Steam provides.

     

    Opinion is my alone so don't quote me on that as LE official statement but what I wrote about the options is 100%, I have published on Steam already.

  11. Is there a way to integrate it without treating it like a mouse, ie can you make it so the game naturally runs the steam controller. I know in the API reference in steamworks there's a controller integration, but it doesn't seem to allow it to naturally work in-game.

     

    Yes it can. You can pull input events via Steam API. But for this to work it needs to be build in on LE level , I guess you can do it yourself if you have C++ edition. In Indie edition there is no way without LE having it as it requires talking to Steam API.

     

    Assuming you have overcome this problem, there is a quite easy way of defining input for your game and creating default layout.

  12. Hi, so I had some time to tinker and I think I got decent but basic bullet. Script that Josh suggested was useful but one thing I'm missing. I cannot make my bullet hit an object/enemy.

     

    My function to create a bullet is :

    function Script:GetBullet(position)
       local bullet = Sprite:Create()
       bullet:SetPosition(position)
       bullet:SetViewMode(2)
       bullet:SetMass(1)
       bullet:SetGravityMode(false)
       bullet:SetCollisionType(Collision.Prop)
       bullet:SetCollisionType(Collision.Projectile)
       bullet.origin = Vec3(position.x,position.y,position.z)
       local mat = Material:Load("Materials/Icons/PointLight.mat")
       if mat then
           bullet:SetMaterial(mat)
           mat:Release()
       end
       return bullet
    end
    
    function Script:UpdateWorld()
    local bullet,n,dist
    local travel
    local bspeed=22--float
    local window = Window:GetCurrent()
    
    for n,bullet in ipairs(self.bullets) do
       dist = (bullet.position-bullet.origin):Length()
    
       if dist>self.bulletrange then
           table.remove(self.bullets,n)
           bullet:Release()
           bullet=nil
       end
    
       if bullet ~=nill then
           travel = bspeed/60.0*Time:GetSpeed()
           bullet.position = bullet.position+Vec3(0,0,travel)
           bullet:SetPosition(bullet.position)
       end
    end
    
    if window:KeyDown(Key.E) then
       local currenttime=Time:GetCurrent()
       if self.lastfiretime==nil then self.lastfiretime=0 end
       if currenttime-self.lastfiretime>self.refirerate then
              self.lastfiretime = currenttime
              local pos = self.entity:GetPosition(true)
              table.insert(self.bullets,self:GetBullet(pos))
       end
    end
    
    self:UpdateCamera()
    end
    

     

    Yeah, I'm shooting light bulbs at the moment smile.png

    Now, I assumed that sprite needs to have properties of a normal object so it can interact with environment but that does not work. Sprite goes right trough the object and nothing happens. My "enemy" script is very simple for now:

     

    function Script:Start()
       self.startposition = self.entity:GetPosition()
       -- Enemy Vars
       self.entity:SetMass(1)
       self.entity:SetGravityMode(false)
       self.entity:SetFriction(0,0)
       self.entity:SetCollisionType(Collision.Prop)
    end
    
    function Script:Collision(entity)
       self.entity:Hide()
    end
    

     

    But if I collide this enemy with my player controller which for now is just a primitive box, all works as expected, collision works.

     

    What I need to do for sprite to trigger this collision ?

    • Upvote 1
  13. I just got this yesterday and considered it a fluke. Today I went through some troubleshooting steps, which included a fresh reinstall and got the same error.

     

    What did you place in steam_appid.txt that got it working?

     

    This is an ID that steam assigns to each product. Here :

     

    http://store.steampowered.com/app/251810/

     

    Number is the steam ID. But this is no hack to make it run outside the Steam. This only allows to run Steam integrated software outside Steam while Steam is running. Best eg. is you can test your new version of software how it works in Steam without uploading it to Steam.

    • Upvote 1
  14. Hi,

    My installation of LE behaves badly today. I had it working just fine few days ago but today is not happy.

     

    So when I run it from Steam I'm getting an error that executable is not found but when I run it from terminal All is nice and working , added steam_appid.txt to make it work.

     

    Looks to me like Steam publishing did not go as expected. Where there was an update ? I'm honestly not sure did 3.6 is now official release recently updated or was it for some time now.

     

    I did remove all content from my box and re-installed LE. Same result.

     

    This cannot be a distro specific but just for FYI , I run LE on Slackware 14.1 with KDE.

     

    Please see attached screenshots.

    post-14775-0-29315500-1447889574_thumb.jpg

    post-14775-0-38978700-1447889584_thumb.jpg

    • Upvote 1
×
×
  • Create New...