Jump to content

Chris Vossen

Members
  • Posts

    688
  • Joined

  • Last visited

Everything posted by Chris Vossen

  1. Try setting the characters physics rotation to 180
  2. Thank you! Josh just fixed it and will include the fix in the next update.
  3. So when you make a new project it includes all the default scripts. If you changed the script in the Darkness Awaits folder and want to use that script in your new project you can copy just copy and past it into the new project's script folder. Also this post might help: http://www.leadwerks.com/werkspace/topic/6081-le3-question-about-starting-a-project/
  4. As far as I know the function is working properly. If it's not let me know!
  5. Quick steps to making a new project: 1. Make sure your current LE3 build is up to date (just click on the installer and click update) 2. Open the project manager File->Project Manager 3. Click "New" 4. Select your project type (I chose Lua for this example), enter a project name, and click okay. 5. Select your project from the list and click okay 6. Create a map, throw in a camera 7. Save your map. 8. Click run.
  6. Hmm when you use the project manager to make a new project it should create a new App.Lua script that shouldn't have anything to do with Darkness Awaits. If you open up the App.Lua script it should look something like this: (except instead of "test2" it should say your project name) --This function will be called once when the program starts function App:Start() --Set the application title self.title="test2" --Create a window self.window=Window:Create(self.title) self.window:HideMouse() --Create the graphics context self.context=Context:Create(self.window,0) if self.context==nil then return false end --Create a world self.world=World:Create() --Load a map local mapfile = System:GetProperty("map","Maps/start.map") if Map:Load(mapfile)==false then return false end return true end --This is our main program loop and will be called continuously until the program ends function App:Loop() --If window has been closed, end the program if self.window:Closed() or self.window:KeyDown(Key.Escape) then return false end --Update the app timing Time:Update() --Update the world self.world:Update() --Render the world self.world:Render() --Refresh the screen self.context:Sync() --Returning true tells the main program to keep looping return true end
  7. Okay I figured it out, the Character Controller Rotation was set to 1.0 it should be set to 0.0.
  8. I created a slimmed down version of a camera script, it doesn't do any fancy raycasting but I feel is fairly readable. Script.target = nil--Entity "Target" Script.distance = 10--float Script.debugphysics = false--bool Script.debugnavigation = false--bool Script.pitch = 20--float Script.height = 10--float function Script:Start() if self.target==nil then return end --debug functions for viewing physics or navigation in game self.entity:SetDebugPhysicsMode(self.debugphysics) self.entity:SetDebugNavigationMode(self.debugnavigation) --Set the cameras rotation self.entity:SetRotation(self.pitch,0,0) end function Script:UpdatePhysics() --Exit the function if the target entity does not exist if self.target==nil then return end --Get the target entitys position, in global coordinates local p0 = self.target:GetPosition(true) --Calculate the new camera offset local offset = Vec3(p0.x,p0.y+self.height,p0.z-self.distance) --Add our original offset vector to the target entity position p0 = offset self.entity:SetPosition(p0,true) end
  9. Along with the way Rastar outlined you could also: Right Click in the Assets Window and choose New->Script
  10. So I tested out your script by attaching it to a box in Darkness Awaits, I then put the camera in the entity field. When I ran the game the box seemed to move how you would expect it to when parented to the camera. If I had to take a random guess I'd say that the object that you are setting as a child of the camera is being moved off screen or behind the camera. I'd check their positions real quick (throw this in after the call to set parent and then check the Output box after running the game: System:Print("camera / tposition: " .. tposition:ToString().." object position: "..self.entity:GetPosition():ToString())
  11. Okay so there are a handful of ways to access an entities information from Lua scripts. 1. If the script is attached to the entity you want to access. In this case you just call self.entity and it refers to the entity that the script is attached to. For example, in the player script (which is attached to the barbarian model) there is a call: self.entity:SetInput(self.currentyrotation,move,0,0,false,self.maxAcceleration) This part confused me when I first started Lua scripting: self.entity refers to the entity that it is attached to, which is the barbarian model. So in my mind it's like calling "Model:SetInput(...)" If you had a script attached to a camera and you wanted to call a camera specific function "Set Range" the function call would be: self.entity:SetRange(range.x,range.y) this is because the entity that the script is attached to is a camera so the call is essentially camera:SetRange(...) 2. If the entity is declared in another Lua Script (And was not declared as local) In App.lua context is created as self.context=Context:Create(self.window,0) to access this from another script you could call App.context:GetWidth() 3. You want access to an entity that is in the editor and the script is not attached to. The simplest way to do this is to declare an entity variable in your script and then select it in the editor. For example in the camera class at the near the top of the script there is a variable "target" and it is declared as Script.target = nil --Entity "Target" By using "--Entity" tag after declaring the variable the editor will now have an entity field in the script tab. You finally can drag and drop an entity from the scene tab to the entity field 4. Various other ways World::ForEachEntityInAABBDo World::ForEachVisibleEntityDo For the specific example of a camera, I would go with option 2 and declare it in app.lua. self.camera = Camera:Create() then access it from other scripts as App.camera
  12. Often times C++ is considered a superset of C (This is not technically true) but it is very close to C. I've always felt that if you can learn C you can learn anything.
  13. Currently we only support the fbx file format. Here is a link to a free autodesk obj to fbx converter: http://usa.autodesk.com/adsk/servlet/pc/item?siteID=123112&id=20481519
  14. Try setting the nav obstacle parameter to true, it's the bottom most check mark on the physics tab One helpful setting that you can use if you are working with the navigation system, is to turn on the show navigation in the editor. View->Show Navigation hopefully this helps
  15. For those of you who are more familiar with C style syntax here are a few oddities that initially threw me off: The not equals in lua has a tilde self.entity ~= nil if you want to "not" a boolean you have to use the keyword "not" if not self.target then All "if" statements you have to do include 3 keywords if, then, end if self.stunned==true then return end While loops have 3 keywords while, do, end While x < 10 do x = x+1 end This is what a for loop looks like: for i = 0, 10, 2 do print ( i ) end in C that same for loop would be: for (i = 0; i <= 10, i += 2) { printf("%d \n",i); } Notice in the Lua for loop that exit condition is always less than or equal to <= so be careful! There are no +=, -=, /=, or *= in lua String concatenation is ".." rather than + There is no need to end each line with a semicolon although it can be used to break up lines of code. This way you don't have to dedicate a whole line to a small declaration. x = 10 ; y = 10; Lua uses tables for everything, instead of arrays and maps. (A table is basically a map though..) tables are declared with {} Script.state={} you can add specific keys and values to this table by: Script.state.idle=0 Script.state.walk=1 Script.state.chase=2 Script.state.attack=3 Script.state.hurt=4 Script.state.dying=5 Script.state.dead=6 Then if you want to know the size of the table use the symbol # #self.state will return 7 In Darkness awaits I always use the short hand function call. Time:GetCurrent() This is expanded to the long hand: (I think this is the correct syntax) Time.GetCurrent(Time) The short hand is cleaner but when you get an error in one of the parameters the debugger will be wrong in the argument number. For example say you called gotopoint with too many arguments (there should only be 5 not 6 self.entity:GoToPoint(20,2,0,0,1.4,1) The debugger would complain and say "argument #7 is 'number';" and you'll think to yourself, there is no argument 7 you crazy debugger.... but this is because the function is expanded to the long hand form so it is actually calling self.entity.GoToPoint(self.entity,20,2,0,0,1.4,1) and you can see the extra argument is actually in the 7th position. Well off the top of my head these are all I can think of. I know there are more. For more in depth lua info check out: http://www.lua.org/pil/contents.html#P1
  16. So Entity::GoToPoint will move the entity if a path is available. The coordinate system is setup such that Y is "up" so -25 would be below the ground and no path will be found. Try changing it to 0.
  17. Quick Answer: goblinai is the name of the script attached to the goblin entity. The declaration of target was actually a slip up on my part, it should have been declared at the top of the script as Script.target = nil. This brings up a good point on how flexible Lua is (which can get you into trouble sometimes) since self.target is not declared anywhere, when something is assigned to it lua creates the variable on the fly. It will not be global because of the prefix "self". Long Answer: To fully understand this code you have to look at these two chunks of code: --Check for a new target in the area if not self.target then if time-self.lastCheckForTargetTime>500 then self.lastCheckForTargetTime=time local position = self.entity:GetPosition(true) local aabb = AABB() aabb.min.x=position.x-self.sightRadius aabb.min.y=position.y-self.sightRadius aabb.min.z=position.z-self.sightRadius aabb.max.x=position.x+self.sightRadius aabb.max.y=position.y+self.sightRadius aabb.max.z=position.z+self.sightRadius aabb:Update() self.entity.world:ForEachEntityInAABBDo(aabb,"EnemyForEachEntityInAABBDoCallback",self.entity) if self.target then self.entity:EmitSound(self.sound.attack[math.random(0,#self.sound.attack)]) self.currentState=self.state.chase self.entity:Follow(self.target.entity,self.speed,self.maxaccel) --self.entity:SetMass(self.mass) self.followingTarget=true end end end and function EnemyForEachEntityInAABBDoCallback(entity,extra) if extra.goblinai.target==nil then if extra~=entity then if entity.player~=nil then extra.goblinai.target=entity.player end end end end Basically if the goblin does not have a target assigned an AABB (axis aligned bounding box) is created around the goblin with a height, width, and depth of the goblins sight radius. self.entity.world:ForEachEntityInAABBDo(aabb,"EnemyForEachEntityInAABBDoCallback",self.entity) The foreachentityinaabbdo function is then called on the newly created aabb. The call back function name "EnemyForEachEntityInAABBDoCallback" is passed in as parameter 2, this means that for every entity within the aabb the callback function "EnemyForEachEntityInAABBDoCallback" will be called. Finally parameter 3 is self.entity which in this case refers to the specific goblin model that the script is attached to. Now the function "EnemyForEachEntityInAABBDoCallback(entity,extra)" extra is the extra passed in from earlier (the goblin model) and entity an entity that that is within the aabb. if extra.goblinai.target==nil then extra is the passed parameter, which was self.entity (the goblin model), goblinai is the specific script attached to the goblin model and target is the variable (which was sloppily created on the fly, my bad). if extra~=entity then You are trying to only find entites with a player script attached. So you begin by making sure that the entity in this call is not the goblin who the aabb is around. if entity.player~=nil then extra.goblinai.target=entity.player end finally if the entity found is not the goblin and has a player script attached (entity.player~= nil) then the goblin's target is the new entity that is found. would not work because the entity that is passed in is not guaranteed to have a player script attached. Wow this was a long winded answer, hopefully it helps a little. I can gladly explain / clarify any specific sections of code.
  18. In the Scene browser click on the object that has the script attached to it, right click on the script tab (example if the script is called animationmanager the tab will be called animationmanager) then chose delete.
  19. Try: adding in an extra backslash return Map:Load("Maps\\start.map")
  20. If you're ever wondering what a function does, every function should have a complete example program in both C++ and Lua. This means you can copy and paste an entire Lua example into App.Lua (Make sure you save a copy of the original somewhere, or you can always delete it and click update on the installer) and click run! Wondering what GoToPoint does? Throw the Lua example in as App.Lua and viola.
  21. The lua example in Model::GetSurface might help as well.
  22. The goblin not following again might possibly be an issue with my goblin AI (I'll have to look into this a little bit later) There is an entity command that needs to be exposed to determine MaxSlope for entities. If the slope is too steep the player will slide down else it will act as a ramp. If you just wanted the visuals of a ramp and the collisions of a "wall" you could set the physics shape to a box. I'll add exposing the command and investigating the following issue onto my todo list (It's a little long at the moment)
×
×
  • Create New...