DigitalHax Posted January 24, 2012 Share Posted January 24, 2012 Hello. I am looking at the character controller function with the leadwerks engine, and I got it all set up, but the camera height was too low. Which brings me to another point. How come in the tutorial for character controllers, it uses a map, scene.gmf, which does not come in the zip! Can someone help me with this? I am a bit of a noob to C++. Thanks in advance. Quote Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5. Life is too short to remove USB safely. Link to comment Share on other sites More sharing options...
Marleys Ghost Posted January 24, 2012 Share Posted January 24, 2012 If memory serves (which it does now and then) somewhere in the murky past the controllers origin was changed from the centre to the base of the controller .. I thnk the position the cam is moved to in that tutorial is a y value multiplied by 0.5 ... try removing the 0.5 Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
DigitalHax Posted January 24, 2012 Author Share Posted January 24, 2012 Works like a charm thanks. Oh and before I forget, how would you. Load a map, (.sbx) instead of a model? Quote Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5. Life is too short to remove USB safely. Link to comment Share on other sites More sharing options...
Rick Posted January 25, 2012 Share Posted January 25, 2012 TEntity scene = LoadScene("abstract::myscene.sbx") Quote Link to comment Share on other sites More sharing options...
DigitalHax Posted January 25, 2012 Author Share Posted January 25, 2012 This works to load it, but the scene doesn't collide with the player. I set the entity type and set the collisions, but it still doesn't collide with the player. Quote Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5. Life is too short to remove USB safely. Link to comment Share on other sites More sharing options...
Rick Posted January 25, 2012 Share Posted January 25, 2012 So you create a character controller for the player and that's what you are setting the entity type on? Did you also give it the character controller a mass? Quote Link to comment Share on other sites More sharing options...
DigitalHax Posted January 25, 2012 Author Share Posted January 25, 2012 Well i created the character controller originally just following the tutorial, it worked fine and had mass and collisions,but it loaded a model instead of a map, so when i loaded a map instead, the map would be there, then you would just fall through it. even if you set it to spawn on top of it, it would still not collide with you in any way. Quote Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5. Life is too short to remove USB safely. Link to comment Share on other sites More sharing options...
Rick Posted January 25, 2012 Share Posted January 25, 2012 I guess you'd have to post your code because if you said you set the correct entity types and collisions with the right collisions response (last param to Collisions()) then it should work. Quote Link to comment Share on other sites More sharing options...
DigitalHax Posted January 25, 2012 Author Share Posted January 25, 2012 This is my code so far. #include "engine.h" int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ) { Initialize() ; RegisterAbstractPath("F:/Leadwerks Engine SDK/Leadwerks Engine SDK"); SetAppTitle( "MyGame-Debug" ); //Create a graphics context Graphics(1280,720); //Create a world if (!CreateWorld()) { MessageBoxA(0,"Error","Failed to create world.",0); goto exitapp; } //Create a camera TEntity cam=CreateCamera(); CameraClearColor(cam,Vec4(0,0,1,1)); PositionEntity(cam,Vec3(0,2,-10)); Collisions(1,2,true); //Load a model TEntity scene=LoadScene("abstract::tunnels.sbx"); PositionEntity(scene,Vec3(3.8,-2.5,0)); if (scene==0) { MessageBoxA(0,"Error","Failed to load model.",0); goto exitapp; } EntityType(scene,2); //Create a light TLight light=CreatePointLight(); PositionEntity(light,Vec3(0,5,0)); //Create a render buffer TBuffer buffer=CreateBuffer(1280,720,BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL); TController player=CreateController(1.8,0.4,0.5,45.01); EntityType(player,1); SetBodyDamping(player,0.0); SetWorldGravity(Vec3(0,-20,0)); SetBodyMass(player,1); PositionEntity(player,Vec3(0,1,0)); float move=0.0; float strafe=0.0; TVec3 camrotation=Vec3(0); float mx=0; float my=0; HideMouse(); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); //Main loop while(!KeyHit(KEY_ESCAPE)) { //Camera looking mx=Curve(MouseX()-GraphicsWidth()/2,mx,6); my=Curve(MouseY()-GraphicsHeight()/2,my,6); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); camrotation.X=camrotation.X+my/10.0; camrotation.Y=camrotation.Y-mx/10.0; RotateEntity(cam,camrotation); //Player movement move=(KeyDown(KEY_W)-KeyDown(KEY_S))*2.0; strafe=(KeyDown(KEY_D)-KeyDown(KEY_A))*2.0; //Jumping float jump=0.0; if (KeyHit(KEY_SPACE)) { if (!ControllerAirborne(player)) { jump=4.0; } } //Run if (KeyDown(KEY_LSHIFT)||KeyDown(KEY_RSHIFT)) { if (!ControllerAirborne(player)) { move*=2.0; strafe*=2.0; } } //Set controller input UpdateController(player,camrotation.Y,move,strafe,jump,40); //Update the world UpdateWorld(); //Position the camera TVec3 playerpos=EntityPosition(player); TVec3 camerapos=EntityPosition(cam); camerapos.Y=Curve(playerpos.Y+1.75*0.5,camerapos.Y,2.0); camerapos=Vec3(playerpos.X,camerapos.Y,playerpos.Z); PositionEntity(cam,camerapos); //Render the scene SetBuffer(buffer); RenderWorld(); //Render lighting SetBuffer(BackBuffer()); RenderLights(buffer); //Swap the front and back buffer Flip(); } exitapp: return Terminate(); Quote Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5. Life is too short to remove USB safely. Link to comment Share on other sites More sharing options...
cassius Posted January 26, 2012 Share Posted January 26, 2012 Is it a terrain or an interior map? 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...
DigitalHax Posted January 26, 2012 Author Share Posted January 26, 2012 Well I am trying to load the tunnels.sbx demo map, which is mostly models. Quote Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5. Life is too short to remove USB safely. Link to comment Share on other sites More sharing options...
DigitalHax Posted January 26, 2012 Author Share Posted January 26, 2012 Another thing, is that when i load the map, it always says, "could not load scripts/classes". I looked in the directory and in the folder is a fpscontroller.lua Quote Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5. Life is too short to remove USB safely. Link to comment Share on other sites More sharing options...
cassius Posted January 26, 2012 Share Posted January 26, 2012 Have you det the tunnels map y to "scene" in its properties. Does it have a phy file and basic lua script. 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...
macklebee Posted January 26, 2012 Share Posted January 26, 2012 you have to copy the entire Scripts folder over into your project folder Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
DigitalHax Posted January 26, 2012 Author Share Posted January 26, 2012 Ok. Well I will try all of your suggestions soon. Meanwhile ill be out for australia day Quote Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5. Life is too short to remove USB safely. 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.