Jump to content

Einlander

Members
  • Posts

    778
  • Joined

  • Last visited

Everything posted by Einlander

  1. Just came across this youtube tutorial for tree[d] and how to get a less than 1000 polygon count tree.
  2. 4. is there a possibility of OnColliderEnter or OnCollisionEnter like in unity or would I have to implement that my self somehow? You would have to Impliment them. But i just did this yesterday. http://www.leadwerks.com/werkspace/blog/120/entry-1186-ladders-are-evil-ugh/ The code is here http://www.leadwerks.com/werkspace/blog/120/entry-1186-ladders-are-evil-ugh/#comment_5104
  3. The collision stuff should be simple enough, my last post has the events needed to code actions for each situation. Ladders on the other hand, imo would require a more robust navmesh. The AI can move around and up and down slopes. But iirc, they cant bridge between separated navmesh areas such as a roof and the ground, unless the slope is gentle enough. So an AI controller would need to be made in conjunction with a compatible ladder script. So making it work with AI is doable, but you will end up needing to replicate parts and systems more mature engines have.
  4. There might be an option in the settings on 3ds max, I don't know where as I dont use it. I know when you export from 3dCoat, one of the first options is 'swap y for z', which essentially makes whatever you modeled look like it was lying down.
  5. Thanks for the help, both your solutions are shorter and more elegant than what I came up with. Also less computationally intensive. I used Ricks code. Here are the changes that i made: -- this will store all entities that collide with this trigger so we can manage them function Script:Start() self.entities = {} end function Script:UpdatePhysics() for i = 1, #self.entities do --lua indexes start at 1 not 0 - einlander if self.entities[i].entered==true then if self.entities[i].hadCollision == false then if self.entities[i].exited == false then -- remove this entity from the table because they left the trigger. we can do whatever with the entity here also self:CollisionOnExit(self.entities[i].entity) --raise event [einlander] table.remove(self.entities, i) break --[einlander for sanity reasons, and not to have to manually incriment the for next loop, finish it on the next run through the function] -- i = i + 1 [commented out - einlander] end end end self.entities[i].hadCollision = false end end function Script:FindEntity(e) for i = 1, #self.entities do --lua indexes start at 1 not 0 - einlander if self.entities[i].entity == e then return self.entities[i].entity end end return nil end function Script:CreateEntityObject(e) local eObject = {} eObject.entity = e eObject.entered = false eObject.hadCollision = true eObject.exited = false return eObject end function Script:Collision(entity, position, normal, speed) -- see if this entity is already actively colliding and if so get it from our list local e = self:FindEntity(entity) -- this is a new entity if we can't find it in our list so add it to our list with it's vars if e == nil then e = entity -- this is a new entity so add it to our list self.entities[#self.entities + 1] = self:CreateEntityObject(entity) self:CollisionOnEnter(entity, position, normal, speed) -- raise event end --[[ For what ever reason, this section did not work, I to assumed that lua passed things by reference, the internet supports this and documentation. Well not happening here, see next section. e.hadCollision = true if e.entered == false then e.entered = true e.exited = false end ]]-- -- check the entity that was passed in here which either exists already or is new and we just added it for i=1 , #self.entities do -- manually find the object we created and set it's attributes [einlander] if self.entities[i].entity==entity then self.entities[i].hadCollision = true self:CollisionOnStay(entity, position, normal, speed) -- raise event if self.entities[i].entered == false then self.entities[i].entered = true self.entities[i].exited = false end end end end -- Called ONCE when something touches trigger for the first time [einlander] function Script:CollisionOnEnter(entity, position, normal, speed) self.component:CallOutputs("CollisionOnEnter") end -- Called CONTINUOUSLY when something is in the trigger [einlander] function Script:CollisionOnStay(entity, position, normal, speed) self.component:CallOutputs("CollisionOnStay") end -- Called OONCE AFTER something leaves the trigger [einlander] function Script:CollisionOnExit(entity) self.component:CallOutputs("CollisionOnExit") end
  6. Ladders, Some people like them, some people don't. I like them, but I don't like making them. I just spent 9 straight hours after work to get the semblance of a half working ladder. The challenges were mind boggling for my sleep addled brain. I initially started a few days ago. I wanted ladders for the game I had planned. Specifically with functionality similar to Counterstrike: Source and Left 4 Dead. So being the lazy good dev I am, I went to Youtube to see how people using Unity were accomplishing it. The first immediate thing I noticed was that they all used triggers/colliders to accomplish this goal. They used 3 features of their trigger/collider: OnEnter, OnStay, and OnExit. I was shown a script where all of the actions were implemented, but I realized from the time I spent making sourcemod scripts that I would need to control every entity that touched my trigger, especially if I ever did multi-player. So I wrote a heavily modified collision trigger. OnEnter was not that hard, all that was is the very first instance that an entity collided with the trigger I call a function once, and add it to a list so it would not be called again. OnStay is just a duplicate of the Collision function in Leadwerks. OnExit was the spawn of satan. On exit tells you when an entity leaves the trigger. Well in Leadwerks when something leaves a trigger it's gone. You can have a list of entites that you populated but since the collision trigger can't tell you whats missing the list becomes useless. So I ended up creating a a list paging system in order to track what entity has left. So I created 2 lists: old and new and a timer : Timetillupdate When an entity collides for the first time I set it's state to onenter. When it collides a second time i change it's state to onstay when timetillupdate runs out i check the old list against the new. If there is something missing in the new list, i set that entity to onexit. Then i page the new list into the old list, then empty the old Seems simple enough, but it's my first time doing this, and Leadwerks is my first game engine where I have coded anything of note, so I probably went the long way round, and messed something up, nevertheless it functioned properly. Now the ladder. After watching about 3 videos on YouTube, This one showed that once you enter the trigger, you takeover the controls then transform the player up the ladder, simple enough. In Leadwerks I used translate to move the player up the ladder. It mostly worked, except that the player couldnt get to the top of the platform. After all sorts of unholy buggery I settled for a dirty trick I read a few places. When they enter the ladder zone, turn off the players gravity, when they get off the ladder, turn it back on. This solved my ladder issue for the most part. When I get more time/experience I will fix the ladder so there are no gravity tricks,and the player can be able to stop mid climb and not slide back down. Or I could simply cop out and force people to press the use button to mount the ladder, and press use again to dismount. Here is the result of my sleepless night:
  7. Or in the settings, or at save time it asks to zero the origin
  8. That annoys me too. All the models packs I made I had to position them at 0,0,0 before I save a prefab. Don't get me started with using a csg as a shape mesh, they don't perfectly align when you do that.
  9. The script you have, when a collision enters,exits and stays it reports an event happens. By indiscriminately I mean that it doesn't take account of which entity entered, or which entity exited. With that script, it doesn't say which entity entered, or which exited. I want the collision script to be able to affect other entities. For example, When an entity enters, set its gravity state off, then when it leaves turn it back on. That script will only know its holding something, not what or how many. Don't worry, I wrote this post after spending an all nighter. I'm writing this post while at work as fast as possible, so I dont know if I'm communicating my idea properly.
  10. True, but that one indiscriminately report when itself has been entered and exited. I need the script to report which entity has exited. I would like the on exit to be able to report the same information the collision event does. Which entity left, and optionally, position and speed
  11. Can a mod move this to the programming section? Is there a way to progamatically get a list of entities that are currently colliding with an object? I would like to be able to get a a list of all the unique entities in a collision trigger then compare it later. For example, a person walks into a room, then leaves. I want to be able to detect when a person leaves the area. I have been partially able to solve some of my needs. --[[ This script will make any entity act as a collision trigger. It works best when you set the entity's collision type to "Trigger". This will continuously detect collisions without causing any physical reaction. --This Has been modified to behave more like the Source Engine/Unity Collision Triggers ]]-- function Script:Start() --Create a table to keep track of all entitys that are interacting with the collision trigger self.CollisionEntites = {} end function Script:Collision(entity, position, normal, speed) --[[ We are going to keep track of 3 things: [Done] When an entity ENTERS the collision trigger [Done] When an entity is IN the collision trigger [] When an entity EXITS the collision trigger ]]-- --When an entity ENTERS the collision trigger if (self.CollisionEntites[entity] )== nil then -- Check table, is the entity already in it? -- No? --check if its in the list local matchfound = false if matchfound == false then for itemnum,value in ipairs(self.CollisionEntites) do if entity == value then matchfound=true end end table.insert(self.CollisionEntites,entity) --add entity to list of objects currenty in the collision trigger if matchfound == false then self:CollisionOnEnter(entity, position, normal, speed) -- Raise CollisionOnEnter event end end -- yes? Call the CollisionOnStay Event self:CollisionOnStay(entity, position, normal, speed) end end function Script:CollisionOnEnter(entity, position, normal, speed) self.component:CallOutputs("CollisionOnEnter") end function Script:CollisionOnStay(entity, position, normal, speed) self.component:CallOutputs("CollisionOnStay") end I can tell when an entity enters, and stays inside. But not when it leaves.
  12. My question is why so many polygons? The picture of the building with the fire escape has 11k tris, and your scenes are rendering in excess of 40k polys, and if you used 3dcoat which likes to turn everything to quads, it reveals your models are pushing almost double to triple the polycount reported by leadwerks. In that one scene of yours, you can fit 4 of those ENTIRE buildings or 1 20 story building with polygons to spare. Now we can do 2 things, 1 would be to lower the poly count, or 2 aggressive occlusion culling. There is no reason to be pushing that many polygons for 2 buildings.
  13. That is what I did, but i added all the keycodes so i would never have to look them up again. So I have a variable, and a function that will look up the keycode for me. and store it in that variable. With the script that I made, I will never have to manually look up the keycodes. I just take the script, assign it to a pivot and everything is finished. If i want to jump i just use window:KeyHit(LW_Jump) and if i want to change the key, i just use the box and change it. I recommend taking a look at the linked scripts, they are an implementation of the ideas in that thread.
  14. I just wrote a blog post about this topic: http://www.leadwerks.com/werkspace/blog/120/entry-1184-key-configs-and-tedium/ Example: http://www.leadwerks.com/werkspace/files/file/515-key-config-host/
  15. This post was inspired by this forum thread http://www.leadwerks.com/werkspace/topic/8942-keys-customisation-shortcut/ by YouGroove A little background of how a concocted this solution. I run a bunch of Left 4 Dead 2 servers and I make mods for them using sourcemod. I find myself having to make special keyconfigs when administrating or adding stuff to the levels. In the process you find out that all actions in the source engine are abstracted. So I adapted that to Leadwerks. When most people program they hard code values for input for thier games. This leads to easy development but later they come up with odd solutions to solve the lack of configuration flexibility. [Abstraction] Some game engines have most everything abstracted away. They refer to animations by name instead of frame range (playercrouch vs playanimtionframes[1,200]) , game events by name instead of number ("hunterpouncebegin" vs action 12345) and player input by name instead of of keycode (player_jump vs Key.Space). The developer defines all the possible input the player can take and gives them a name. Then they apply a keycode to the name. This method allows them to change the actions value at anytime they choose. Psudeocode: Dim Player_Action_Jump as integer 'Create action Player_Action_Jump = Keys.Space 'assign keycode to action If ME.Keydown = Player_Action_Jump then 'detect if the action was taken Jump() ' do something End If Please excuse the vb.net code thats what i'm most use to So now Applying it to Leadwerks: [Application] We will be using the Fpsplayer.lua script and another script that we create. First we Figure out what key inputs the script takes, and that would be: Forward Backwards Strafe Left Strafe Right Jump Flashlight Use Reload Crouch -- this one is comented out but I included it anyway Run Taking this list of actions we create another script that will hold all the actions and key configs. Script.L_Forward Script.L_Backwards Script.L_StrafeLeft Script.L_StrafeRight Script.L_Jump Script.L_Flashlight Script.L_Use Script.L_Reload Script.L_Crouch Script.L_Run The first thing I did was make them all string inputs. But soon I discovered that you couldn't write a shift in an input box, and space would confuse someone. So I made them each a drop down box where you can select the key. Script.L_Forward =22 --choice "Forward" "UNASSIGNED,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,NUMPAD0,NUMPAD1,NUMPAD2,NUMPAD3,NUMPAD4,NUMPAD5,NUMPAD6,NUMPAD7,NUMPAD8,NUMPAD9,NUMPADPERIOD,NUMPADDIVIDE,NUMPADMULTIPLY,NUMPADSUBTRACT,NUMPADADDITION,BACKSPACE,CAPSLOCK,LCONTROL,DELETE,DOWN,END,ENTER,HOME,INSERT,LEFT,NUMLOCK,PAGEDOWN,PAGEUP,RCONTROL,RIGHT,SHIFT,SPACE,SUBTRACT,TAB,UP,EQUALS,OPENBRACKET,BACKSLASH,SEMICOLON,QUOTES,COMMA,SLASH,PERIOD" I had to look all the keys up and then write them all down and make sure i didn't misspell any of them. Also I had to remove some keys from the list -- tilda[~] escape [esc] and the windows key --. Now that you have the selectors for the keys you need to assign the keycode to a global action variable. NOTE: lua does not have select case switches function Script:Start() -- Assign key values to standard movement globals --LW_ stands for Leadwerks or local world LW_Forward =self:AssignKeyFromChoice(self.L_Forward) LW_Backwards =self:AssignKeyFromChoice(self.L_Backwards) LW_StrafeLeft =self:AssignKeyFromChoice(self.L_StrafeLeft) LW_StrafeRight =self:AssignKeyFromChoice(self.L_StrafeRight) LW_Jump =self:AssignKeyFromChoice(self.L_Jump) LW_Flashlight =self:AssignKeyFromChoice(self.L_Flashlight) LW_Use =self:AssignKeyFromChoice(self.L_Use) LW_Reload =self:AssignKeyFromChoice(self.L_Reload) LW_Crouch =self:AssignKeyFromChoice(self.L_Crouch) LW_Run =self:AssignKeyFromChoice(self.L_Run) -- More standard key binds will be added later end function Script:AssignKeyFromChoice(KeyAsChoice) -- Looked it up, Lua DOES NOT have select case if KeyAsChoice ==0 then return 0 end if KeyAsChoice ==1 then return Key.A end if KeyAsChoice ==2 then return Key.B end if KeyAsChoice ==3 then return Key.C end if KeyAsChoice ==4 then return Key.D end if KeyAsChoice ==5 then return Key.E end if KeyAsChoice ==6 then return Key.F end if KeyAsChoice ==7 then return Key.G end if KeyAsChoice ==8 then return Key.H end if KeyAsChoice ==9 then return Key.I end : :Rest of code : end That's the code that handles user input. Make a pivot in the level then attach the script to it. Now this part is simple Go through the fps player script and change all the keycodes to your actions if self.weapon~=nil then if window:KeyHit(Key.R) then self.weapon:Reload() end end BECOMES: if self.weapon~=nil then if window:KeyHit(LW_Reload) then self.weapon:Reload() end end And so on. Now you can change any of the keys to what to what you want at anytime The only shortcomings is this does not support mouse commands. In a future version I might be able to write an input function that reads both the mouse and keyboard commands. Edit: Here Is this idea in action. The Fps player is modified to look for a variable containing the keycodes, and the other script holds the keycodes and lets you change them http://www.leadwerks.com/werkspace/files/file/515-key-config-host/
  16. Some free tree generators: tree[D]: http://www.frecle.net/?show=treed.about arbaro: http://arbaro.sourceforge.net/ they both export to obj.
  17. I have a model that has multiple parts to it. In the model editor I drag a material to model to apply the material, but there are some parts that I can not apply the material to no matter how close I zoom in. my request is to also be able to drag the material onto the name of the object to apply it.
  18. This could be an opportunity for someone to make an entity digging tool that works on the mapfile. Thus is a very little used feature of the source engine. I don't know how valve implements it but I have an idea, provided someone can read the map file and extract all objects/entities from the scene. You would have a master map file. The tool would find all references to models, csgs, scripts, materials and compares them to a new file. When an object in the new file is not exactly as referenced in the old file both objects are flagged and someone needs to approve the change. When all changes are approved a new map file is created with all the changes. I can only propose a solution and not actually work on it currently. I have a bit too much on my plate. And my barricade model pack is almost a week overdue.
  19. Can't you use the face select in the editor and apply an invisible material to the face you want to delete?
  20. If we go through with this, how would we organize? Would it be done by committee? Would people need apply for positions? Or would it be open for anyone to contribute? Can we get away with just having a wiki for it, or do we need to create a forum too? Also how will we share the code? Svn, CVS, git is all nice and stuff, but the map itself does not lend itself versioning. Would everything need to be made out of a prefab and placed into a map so the map parts can be edited externally. And creating standards. There is a minimum square size that the have mesh/csg needs be before the navmesh works, and a minimum hight that can be used for a doorway. We have alot of things that we need to figure out before we start the project and after we start it, but count me in.
  21. I would get some mind mapping software and use that to plot out the flow of the game. I also use Articy: Draft SE as its designed exatly for this task. http://store.steampowered.com/app/230780/.
  22. Does it change if you run it full screen? I know my PC kicks into its sli/crossfire mode and gives me some extra fps. But I'm not making any major use of shaders.
  23. I use 3.1 because c++ is not my specialty. At my skill level I'm not doing too much that will tax the engines capabilities. I just need some lighting and the ability to push polygons, no shaders so far. I do have 3.0 if I really need the extra control.
×
×
  • Create New...