Jump to content

Einlander

Members
  • Posts

    778
  • Joined

  • Last visited

Everything posted by Einlander

  1. When I start Leadwerks and open the script editor, the title area is off the screen:
  2. You can raycast from the front and top of the character controller to the ground. And another ray from the bottom faceing front. If while crouched the bottom raycast hits something with an angle greater than 45, and the top ray has a correct step height, move the player up by step height + 1cm. The controller should take care of the rest.
  3. Read the all the comments on this blog: http://www.leadwerks.com/werkspace/blog/120/entry-1575-einlanders-halloween-devlog/#commentsStart
  4. I also have a trigger script. It is a comprehensive clone of the unity functions. It keeps track of every entity that enters, stays, and leaves a trigger. It also provides 3 functions that other scripts can use to interact with the trigger. It gives you the option of triggering on props, characters, and projectiles --[[ Title: Enhanced Collision Trigger By: Einlander Version: 1.0 First public release Function: Per-Entity collision trigger. With an additional OnTriggerExit output. Made to mimic unity3d collision handler Details: Some times you need to have a trigger that will not only know that it is triggered, but know how many entities triggered it, and when any given trigger has left it's trigger area. Extras: Provides 3 new trigger functions for other scripts to use. Notes: -- on collision a collision has happened Check if the entity is on the entity collision list If not, it is placed on the entity list call OnEnter If it is on the entity list call OnStay -- check during physics -because it's certian to be run, but not as often as update world check to see if collision happened last run No collision has happened last time because collision flag is still off remove from entity list OnTriggerExit Collsion happened set the entity collision flag to false wake up the entity so the trigger will continue detecting it. ]]-- Script.enabled = true --bool "Enable" Script.debugtext = false -- bool "Debug Text" Script.spoofcollision = false --bool "Spoof Trigger" Script.triggerProps = true --bool "Trigger Props" Script.triggerCharacters = true --bool "Trigger Characters" Script.triggerProjectiles = true --bool "Trigger Projectiles" function Script:Start() if self.spoofcollision then -- [spoof collision trigger] dont know if this would actually work Collision.EnhancedCollisionTrigger = Collision.Trigger --Masqurade as the original trigger collision else Collision.EnhancedCollisionTrigger = Time:GetCurrent() -- hopefully no collisions here end -- make sure the trigger interacts with most things -- should be selectable if self.triggerProps then Collision:SetResponse(Collision.EnhancedCollisionTrigger, Collision.Prop, Collision.Trigger) end if self.triggerCharacters then Collision:SetResponse(Collision.EnhancedCollisionTrigger, Collision.Character, Collision.Trigger) end if self.triggerProjectiles then Collision:SetResponse(Collision.EnhancedCollisionTrigger, Collision.Projectile, Collision.Trigger) end self.entity:SetCollisionType(Collision.EnhancedCollisionTrigger) self.entitydb = {} end function Script:Enable()--in if self.enabled==false then self.enabled=true --self.component:CallOutputs("Enable") end end function Script:Disable()--in if self.enabled then self.enabled=false --self.component:CallOutputs("Disable") end end function Script:OnTriggerEnter(entity) end function Script:OnTriggerStay(entity) end function Script:OnTriggerExit(entity) end function Script:UpdatePhysics() if self.enabled then -- check to see if entity is still inside the trigger for key, value in pairs (self.entitydb) do if self.entitydb[key].hadcollision == false then -- check if the entity had a collision from the last check -- on exit self.component:CallOutputs("OnTriggerExit") self:OnTriggerExit(self.entitydb[key].entity) if self.entitydb[key].script then if type(elf.entitydb[key].script.OnTriggerExit)=="function" then -- Check to see if entity has a script with the right function in it, then call it. self.entitydb[key].script:OnTriggerExit(self.entity) end end table.remove(self.entitydb, key) -- got to remove it, or else we will end up indexing nil values else self.entitydb[key].hadcollision = false -- set it to false because if it is still in the trigger it will get activated again self.entitydb[key].entity:AddForce(0,0,0) -- wake up the entit's physics. This is a work around because by default, physics objects go to sleep and the trigger can no longer see them. doesnt actually move entity end end end end function Script:Collision(entity, position, normal, speed) if self.enabled == true then -- check if entity is in the list local entitymatch = false for key, value in pairs (self.entitydb) do if self.entitydb[key].entity == entity then -- found it in the list self.entitydb[key].hadcollision = true entitymatch = true self.component:CallOutputs("OnTriggerStay") self:OnTriggerStay(entity) if entity.script then if type(entity.script.OnTriggerStay)=="function" then -- Check to see if entity has a script with the right function in it, then call it. entity.script:OnTriggerStay(self.entity) end end end end if entitymatch == false then -- add new object to the list local newEntity = {} newEntity.entity = entity newEntity.hadcollision = true table.insert(self.entitydb, newEntity) entitymatch = true self.component:CallOutputs("OnTriggerEnter") self:OnTriggerEnter(entity) if entity.script then if type(entity.script.OnTriggerEnter)=="function" then -- Check to see if entity has a script with the right function in it, then call it. entity.script:OnTriggerEnter(self.entity) end end end end end --This function will be called when the entity is deleted. function Script:Detach() ReleaseTableObjects(self.entitydb) end function Script:PostRender(context) if self.enabled then if self.debugtext then context:SetBlendMode(1) context:SetColor(1,1,1) context:DrawText("Total Contained Entities: " .. #self.entitydb,0,36) end end end Entities interacting with the trigger can use: function Script:OnTriggerEnter(entity) end function Script:OnTriggerStay(entity) end function Script:OnTriggerExit(entity) end
  5. This looks like a good option for a game contest.
  6. you can use luajit ffi, if you have to. http://www.leadwerks.com/werkspace/blog/120/entry-1182-luajit-awesome-luajit-enet-loaded/ the code there is super old, so just take it as inspiration because it's so bad. This are some repos that deal with curl in lua. https://github.com/Playermet/CurLua https://gist.github.com/LPGhatguy/09d3955207ab35d96e97 These will not work in the sandbox and thus not in the game player. As you probably know. You need to have the proper curl lib for the os installed in the same directory as the exe.
  7. See the comments on this blog http://www.leadwerks.com/werkspace/blog/120/entry-1575-einlanders-halloween-devlog/
  8. In my game my approach will be similar to the way Left 4 dead did it. on page 29 to 36. http://www.valvesoftware.com/publications/2009/ai_systems_of_l4d_mike_booth.pdf Raycast periodically above the player to find ceilings and paths..
  9. Make a material with the 'transparent.shader' Then use this code: function Script:Start() if not DEBUG then local material = Material:Create() material:SetBlendMode(5)--Blend.Invisible self.entity:SetMaterial(material) material:Release() end end This will make whatever the object is invisible at runtime (F6), but visible when debugging (f5) or in the editor.
  10. I have done something similar. I had a script that registered players to a playermanager. The player manager is added to a pivot function Script:Start() --= self.entity.script:overwatch_registerplayer(playerEntity) --[[ REQUIRE A CERTIAN OVERWATCH VERSION AND ABOVE. OVERWATCH VERSION SHOULD ALSO STATE HOW FAR BACK IT STAYS COMPATIBLE ]] -- Would prefer that the manager finds the entities itself, but thats not a very easy task without ahead of time preperations before this script is even loaded -- so we have the players self register -- Register it's existance if overwatch ~= nil then if overwatch.playermanager == nil then overwatch.playermanager = {} overwatch.playermanager.players = {} overwatch.playermanager.enabled = true overwatch.playermanager.entity = self.entity overwatch.playermanager.instances = 0 end else Debug:Error("Overwatch System Not Loaded") end overwatch.playermanager.instances = overwatch.playermanager.instances + 1 -- i thought it would be intresting to know how many times an overwatch unit is placed in the map -- If the same script that saet the entity first is not the same one doing the test, we have too many entities if overwatch.playermanager.entity ~= self.entity then Debug:Error("Multiple inscances of Overwatch Player Manager: " .. tostring(overwatch.playermanager.instances) .. " instances") -- it wont even get past 2 end end function Script:overwatch_registerplayer (playerEntity) -- Adds player to the list of forces to be acted apon local i for i =0, #overwatch.playermanager.players, 1 do if overwatch.playermanager.players == playerEntity then return false -- its already in it end end table.insert(overwatch.playermanager.players,playerEntity) return true end function Script:overwatch_unRegisterplayer (playerEntity) -- Remove player from the list of forces to be acted apon local i for i =0, #overwatch.playermanager.players, 1 do if overwatch.playermanager.players == playerEntity then table.remove(overwatch.playermanager.players,i) return true end end return false -- its already removed/never added end function overwatch_registerplayer (playerEntity) -- global function: points to local function overwatch.playermanager.entity.script:overwatch_registerplayer(playerEntity) end function overwatch_unRegisterplayer (playerEntity) -- global function: points to local function overwatch.playermanager.entity.script:overwatch_unRegisterplayer(playerEntity) end --[[ function Script:UpdateWorld() end --]] --[[ function Script:UpdatePhysics() end --]] --[[ function Script:Collision(entity, position, normal, speed) end --]] --[[ function Script:Draw() end --]] --[[ function Script:DrawEach(camera) end --]] --This function will be called after the world is rendered, before the screen is refreshed. --Use this to perform any 2D drawing you want the entity to display. function Script:PostRender(context) context:SetBlendMode(Blend.Alpha) context:SetColor(1,1,1,1) context:DrawText("PlayerManager Player Count:" .. tostring(#overwatch.playermanager.players),2,200) context:SetBlendMode(1) context:SetColor(0,0,0,0.5) end --[[ --This function will be called when the entity is deleted. function Script:Detach() end --]] --[[ --This function will be called when the last instance of this script is deleted. function Script:Cleanup() end --]] And in the Fps player script we register it. function Script:Start() overwatch_registerplayer(self.entity) end I basically created a global function that pointed to a local function. If I wanted I could have the player manager poll in the Script:UpdateWorld() and do things to the players. That was the goal, but I never had enough time to do what I envisioned and dropped the project. Edit-- This is the base system that everything loads into. Also added into a pivot if overwatch == nil then -- Create the base table that all Overwatch systems use. overwatch = {} end it loads a global table for all the other modules to find.
  11. How much more expensive is this shader renderwise?
  12. **Operating system or device - Leadwerks Version:** Windows 7 Pro x64 Leadwerks 4.2 Beta BuildID:1479910 **Issue description** (what happened, and what was expected): -Issue: Models added to the terrain vegetation layer do not show up in game. The same model used for vegitation will reflect if manually dragged into the world. [*]-What was expected Models to show reflection in the water. **Steps to reproduce:** Create scene. Add terrain Add skybox Add models to vegetation layer Run Game **Link to minimal example project** No project just an images: **EDIT** So It seems that the game defaults to a medium water quality instead of high. :/
  13. Things have progressed while I haven't been around. I also ran into your scaling issue a while back. http://www.leadwerks.com/werkspace/topic/11768-contextsetscale-breaks-some-drawing-commands/page__hl__setscale
  14. Great if you are using c++ but the lua export version doesn't support linking to external files.
  15. Ehhh rather not. I like to have my steam account divorced from my online presence. I have people actually trying to do real harm to my game servers and steam group users.
  16. Einlander

    Relocation

    You could always buy a shack in the mountains and become a hermit.
  17. Einlander

    Relocation

    Don't know about Illinois, it kinda corrupt here and the state is basically broke.
  18. This is what I found when I was programming something. it also has resources and sources I used linked function Script:LookAt(start,target) --http://www.leadwerks.com/werkspace/topic/10191-short-example-of-mathatan2/page__hl__lookat --http://stackoverflow.com/questions/1251828/calculate-rotations-to-look-at-a-3d-point --http://leadwerks.wikidot.com/wiki:face-entity --// Calculate angle from point A towards point B local tv = (target - start) local tRoty = Math:ATan2(tv.x, tv.z) --local tRotx = if tv.z >= 0 then tRotx = -Math:ATan2(tv.y* Math:Cos(tRoty), tv.z) else tRotx = Math:ATan2(tv.y* Math:Cos(tRoty), -tv.z) end tRotz = Math:ATan2( Math:Cos(tRotx), Math:Sin(tRotx) * Math:Sin(tRoty) ) return Vec3(tRotx,tRoty,tRotz-90) end
  19. The flow-graph absolutely needs to have a node that only exists in the flow-graph. This way you don't end up polluting your scene with pivots and users can share scripts making it easier to program a game without actually coding. All it needs is a list of available nodes to the left.
  20. You also have the choice of adding the script to a pivot, and the sphere to the pivot at the height you want. This will let it appear as if it's floating while the character controller is actually on the ground.
  21. You would need to use add force to use physics to push your controller where you want. I'll have a go at adding a jetpack to the default fps controller tomorrow. ---Edit-- So it seems that with the 'Character Physics' mode Leadwerks applies different rules to the entity. Thusly this means that you can not reliably nullify the falling of the Character controller with proper math. I'm still working on getting the Jetpack to work no matter the mass or gravity with the character controller. Cross your fingers.
  22. Find the exe folder. In an empty area of the window hold shift and right click. Click start command prompt her. Type your games exe name. Also make sure your app/main.lua file is actually loading the right map. By default it's start.map
  23. Doesn't daz have another product specifically for games now?
  24. I just re-checked, you are right macklebee. If it is reachable it will move to that point regardless of how it is called. Honestly I think it should not move if you have it in an if then statement, but that's another matter.
  25. if player:GoToPoint(x,y,z) then end This means can the player reach the point, yes or no. It doesn't tell the player to actually go there though.
×
×
  • Create New...