Chris Vossen Posted March 6, 2013 Share Posted March 6, 2013 If I was going to make 1 tutorial, what subject would you want it to be on? Quote Link to comment Share on other sites More sharing options...
Marcus Posted March 6, 2013 Share Posted March 6, 2013 My list would be small gem tutorials: Character Controller Pickups Projectile Weapons Melee Weapons AI NOTE: I'm heavily biased towards the FPS genre. Quote Link to comment Share on other sites More sharing options...
gordonramp Posted March 6, 2013 Share Posted March 6, 2013 As Marcus said. Also a standard First person to Third person controller change by keypress. Quote AMD Athlon x2 7750 2.7ghz, 6gb ddr2 ram, Galaxy9800GT 1gig ddr2 video card, Windows 7,64. Link to comment Share on other sites More sharing options...
gamecreator Posted March 6, 2013 Share Posted March 6, 2013 Edit: this may be a bit more advanced: a third person camera that adjusts to avoid going through walls. Quote Link to comment Share on other sites More sharing options...
cassius Posted March 6, 2013 Share Posted March 6, 2013 third person camera Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
YouGroove Posted March 6, 2013 Share Posted March 6, 2013 Third Person camera with : - mouse character orientation - keys for walk forward / backward - rocket launcher (creation of the projectile , moving it , and detect collision something collidable) I think we should not include Golbin or ennemy caus it will complicate the code, if the tutorial will contain some weapon , detection against somehting collidable and juts play a sound when hit, will be more simple. So i would say, no AI states that will make more code and make less clear. For code perhaps several Lua files : - animations.lua (it would receive only one parameter like "walk", "idle") - thirdCamera.lua (a real that rotates with the player orientation, not a travelling one) - launcher.lua (for the weapon code) Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Chris Vossen Posted March 6, 2013 Author Share Posted March 6, 2013 This isn't a tutorial but I uploaded a FreeLook (which I basically stole from Josh) camera that uses the WASD keys and mouse movements. http://www.leadwerks.com/werkspace/files/file/405-freelooklua/ While it's not a true FPS camera, you hopefully could augment it to fit your project. Quote Link to comment Share on other sites More sharing options...
gordonramp Posted March 6, 2013 Share Posted March 6, 2013 Thanks, it's a start. I notice that when attached to a camera, it makes the camera slowly but 'continuously' move (when the keys are not pressed).. I tried adding mass to the camera to stop it without success. Any ideas how it can be stabilised? Quote AMD Athlon x2 7750 2.7ghz, 6gb ddr2 ram, Galaxy9800GT 1gig ddr2 video card, Windows 7,64. Link to comment Share on other sites More sharing options...
Chris Vossen Posted March 7, 2013 Author Share Posted March 7, 2013 Here is the start of a 3rd person camera. I'll write up a blog explaining the code tomorrow: http://www.leadwerks.com/werkspace/files/file/406-3rd-person-camera/ For those who don't want to click download you can copy and paste this: Script.target = nil--Entity "Target" Script.distance = 5--float Script.debugphysics = false--bool Script.debugnavigation = false--bool Script.pitch = 35--float Script.angle = 180--float Script.pickradius = 0.5--float Script.verticaloffset = 1.8--float Script.smoothness = 30--int 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) end function Script:UpdatePhysics() --Exit the function if the target entity doesn't exist if self.target==nil then return end local originalcamerapos = self.entity:GetPosition(true) local targetpos = self.target:GetPosition(true) local newcamerapos = self.target:GetPosition(true) targetpos.y = targetpos.y+self.verticaloffset self.entity:SetPosition(targetpos) self.entity:SetRotation(self.target:GetRotation(true)) self.entity:Turn(self.pitch,self.angle,0) self.entity:Move(0,0,-self.distance) local targetpickmode = self.target:GetPickMode() self.target:SetPickMode(0) --so that the pick doesn't hit the target newcamerapos = self.entity:GetPosition() local pickinfo = PickInfo() if (App.world:Pick(targetpos,self.entity:GetPosition(),pickinfo,self.pickradius,true)) then newcamerapos = pickinfo.position end newcamerapos.x = Math:Curve(originalcamerapos.x,newcamerapos.x,self.smoothness/Time:GetSpeed()) newcamerapos.y = Math:Curve(originalcamerapos.y,newcamerapos.y,self.smoothness/Time:GetSpeed()) newcamerapos.z = Math:Curve(originalcamerapos.z,newcamerapos.z,self.smoothness/Time:GetSpeed()) self.entity:SetPosition(newcamerapos) self.target:SetPickMode(targetpickmode)--return pick mode to original value end Quote Link to comment Share on other sites More sharing options...
YouGroove Posted March 7, 2013 Share Posted March 7, 2013 Thanks Rick , i will try that tonight ********************* Could we have some character movement later ? Only orientation and simple move in space with mouse for direction if possible (no animation and other AI states) I mean a moving cube, to keep code as simple as possible Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Chris Vossen Posted March 8, 2013 Author Share Posted March 8, 2013 Okay I posted some 3rd person movements code : http://www.leadwerks.com/werkspace/files/file/407-3rd-person-controls/ As well as a blog on how to set up a 3rd person scene: http://www.leadwerks.com/werkspace/blog/110/entry-1057-setting-up-a-map-with-3rd-person-controls-and-camera/ And a step by step code walkthrough of the 3rd person camera: http://www.leadwerks.com/werkspace/blog/110/entry-1058-third-person-camera-code-walk-through/ Quote Link to comment Share on other sites More sharing options...
Chris Vossen Posted March 8, 2013 Author Share Posted March 8, 2013 Thanks, it's a start. I notice that when attached to a camera, it makes the camera slowly but 'continuously' move (when the keys are not pressed).. I tried adding mass to the camera to stop it without success. Any ideas how it can be stabilised? Weird, I can't seem to recreate this. For me the camera just floats in mid air. If you zip a copy of your project and msg me with it I'll open it and take a look. Quote Link to comment Share on other sites More sharing options...
gordonramp Posted March 8, 2013 Share Posted March 8, 2013 Weird, I can't seem to recreate this. For me the camera just floats in mid air. If you zip a copy of your project and msg me with it I'll open it and take a look. Message with link sent. Quote AMD Athlon x2 7750 2.7ghz, 6gb ddr2 ram, Galaxy9800GT 1gig ddr2 video card, Windows 7,64. Link to comment Share on other sites More sharing options...
YouGroove Posted March 8, 2013 Share Posted March 8, 2013 @Chris : When you'll have time, if you could post some lines about Mouse to manage direction of the character ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
YouGroove Posted March 9, 2013 Share Posted March 9, 2013 @Chris : thanks we have the free camera system now. For rocket launcher code,, what would you use ? a rocket we put below ground and just place after weapon when player fires ? For collision Axis box collision between rocket and mob ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Chris Vossen Posted March 11, 2013 Author Share Posted March 11, 2013 @Chris : thanks we have the free camera system now. For rocket launcher code,, what would you use ? a rocket we put below ground and just place after weapon when player fires ? For collision Axis box collision between rocket and mob ? In the editor I'd create a rocket model, set it's physics shape and collision type, attach a particle effect, and then save it as a prefab. Then in code I'd use the prefab load function:Prefab @Chris : When you'll have time, if you could post some lines about Mouse to manage direction of the character ? If I can find the time, maybe. What sort of mouse movement are you thinking of? Quote Link to comment Share on other sites More sharing options...
YouGroove Posted March 12, 2013 Share Posted March 12, 2013 Thanks for the tip on prefab. the fisrt would be some 360 direction input by mouse for the character or for some space ship : On Android instead of mouse it would be some full 360 Android circle pad. *********************** The second idea was but for later would be some RTS style unit movement : You click on terrain or any model level with mouse and your unit or character goes to that position. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Chris Vossen Posted March 12, 2013 Author Share Posted March 12, 2013 Thanks for the tip on prefab. the fisrt would be some 360 direction input by mouse for the character or for some space ship : On Android instead of mouse it would be some full 360 Android circle pad. *********************** The second idea was but for later would be some RTS style unit movement : You click on terrain or any model level with mouse and your unit or character goes to that position. I'm just going to quickly post these 2 bits of code: Top Down Camera: 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 camera's rotation self.entity:SetRotation(self.pitch,0,0) end function Script:UpdatePhysics() --Exit the function if the target entity doesn't exist if self.target==nil then return end --Get the target entity's 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 Character movements: (on a goblin model) Script.camera = nil --Entity "camera" --Define animation sequences Script.sequence={} Script.sequence.walk=5 Script.sequence.idle=6 function Script:Start() self.currentyrotation = self.entity:GetRotation().y self.modelrotation = -90 App.window:ShowMouse() end function Script:UpdatePhysics() local window = Window:GetCurrent() local move = (window:MouseDown(Key.LButton) and 1 or 0) local playerscreenpos = self.camera:Project(self.entity:GetPosition(true)) local mousescreenpos = window:GetMousePosition() local vectorbetween = mousescreenpos - playerscreenpos self.currentyrotation = Math:ATan2(vectorbetween.y, vectorbetween.x) + self.modelrotation self.entity:SetInput(self.currentyrotation,move,0) if move ~= 0 then self.entity.animationmanager:SetAnimationSequence(self.sequence.walk,0.04,200) else self.entity.animationmanager:SetAnimationSequence(self.sequence.idle,0.05,200) end end To understand the code basically Math::ATan2 finds the angle between the mouse and the player Camera::Project takes the character position in global space and converts it to screen space. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted March 12, 2013 Share Posted March 12, 2013 thanks a lot Chris That's heavy pieces of code, and i would like to test if i can make some space game like this one. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
shadmar Posted March 13, 2013 Share Posted March 13, 2013 If you get time, how you did these would be interesting to learn about : http://www.leadwerks.com/werkspace/page/videos/_/-r160 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.