Jump to content

Braqoon

Members
  • Content Count

    68
  • Joined

  • Last visited

Everything posted by Braqoon

  1. So bullet only can travel forward in my game and cannot be fired from an angle so it travels only forward (on one vector) with constant speed until hit or end of life. I have tested so far on only one model and collision so far works as it should.
  2. OK issue resolved. As pointed out correctly travel var was here to blame, changing it to Vec3 sort's the problem out. if self.entity.world:Pick(bullet.position,bullet.position+Vec3(0,0,travel),pickinfo,0,true,Collision.Projectile) then Thanks for pointing it out.
  3. As you probably seen my posts in programming section of the forum, I'm try to create something as well. This is my first go at 3D engine but it's going OK minus my little frustrations self-inflicted or otherwise. I'm doing an simple Shm'up and I hope to provide one playable level. Will share some screenshots soon. Based on feedback it might grow to something bigger.
  4. Point taken, thanks. Will check this later.
  5. Well that's just copy & paste from FPSGun.lua script. I have not altered this.
  6. 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.
  7. 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
  8. 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.
  9. 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.
  10. sure, Can provide project. Will create from scratch with same scripts so will do test myself as well. Bare with me.
  11. I will do a video, very easy to replicate.
  12. 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
  13. 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.
  14. self.entity:Release() does the trick but docs should be updated on self.entity:Hide() if it does not do what it says. Thanks.
  15. 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.
  16. 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.
  17. 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.
  18. Cool, might publish something then
  19. 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.
  20. Braqoon

    Steam Controller

    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.
  21. 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 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 ?
  22. Braqoon

    Steam Controller

    Steam controller works of steam API integration so adding to LE it should be not a problem, but this must be done in LE code at least for Indie edition.
×
×
  • Create New...