MrIslomaniac Posted February 1, 2010 Share Posted February 1, 2010 I just made a new Player class for me but my controller now does not seem to work anymore, it just get stuck in the air where it is created(neither gravity nor collision). I also tried the tutorial for controllers, but that does not work either ... any clues? #include "engine.h" int main(int argc, char** argv) { Initialize(); //Create a graphics context Graphics(800,600); //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 TModel scene=LoadModel("scene.gmf"); 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(800,600,BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL); TController player=CreateController(); EntityType(player,1); SetBodyDamping(player,0.0); SetWorldGravity(Vec3(0,-20,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); strafe=KeyDown(KEY_D)-KeyDown(KEY_A); //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); //Update the world UpdateWorld(); //Position the camera TVec3 playerpos=EntityPosition(player); TVec3 camerapos=EntityPosition(cam); camerapos.Y=Curve(playerpos.Y+1.75,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(); } I think I am just missing something like SetCollision or SetMass ... Greetz Quote Link to comment Share on other sites More sharing options...
Marleys Ghost Posted February 1, 2010 Share Posted February 1, 2010 Have you set body mass for the controller? 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...
MrIslomaniac Posted February 1, 2010 Author Share Posted February 1, 2010 Since that is the complete code, no Ok that works now =) thank you! Thought that i can't do that because it requires a TBody ... Happy Quote Link to comment Share on other sites More sharing options...
Marleys Ghost Posted February 1, 2010 Share Posted February 1, 2010 Since that is the complete code, no Ok that works now =) thank you! Thought that i can't do that because it requires a TBody ... Happy No problems, I never actually looked through your code as the problem is 99.9% of the time not giving the controller mass. 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...
Elmar Posted February 18, 2010 Share Posted February 18, 2010 I have the same problem, but i can't resolve this problem. Can you show me in the code above what you say? thanks. Quote Link to comment Share on other sites More sharing options...
Marleys Ghost Posted February 18, 2010 Share Posted February 18, 2010 add: SetBodyMass(player,1); 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...
Elmar Posted February 18, 2010 Share Posted February 18, 2010 But when i add it my controller became very heavy and it began to move off scene. Maybe i do any another mistake? Quote Link to comment Share on other sites More sharing options...
Marleys Ghost Posted February 18, 2010 Share Posted February 18, 2010 Change: UpdateController(player,camrotation.Y,move,strafe,jump); try: UpdateController(player,camrotation.Y,move*3,strafe*3,jump,500.0f); 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...
Elmar Posted February 18, 2010 Share Posted February 18, 2010 it doesn't work again ( Quote Link to comment Share on other sites More sharing options...
macklebee Posted February 18, 2010 Share Posted February 18, 2010 post your code so someone can see whats happening. without the code they can only guess. 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...
Marleys Ghost Posted February 18, 2010 Share Posted February 18, 2010 post your code. 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...
Elmar Posted February 18, 2010 Share Posted February 18, 2010 #include "engine.h" int main(int argc, char** argv) { Initialize(); //Create a graphics context Graphics(1280,768); //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 TModel scene=LoadModel("c://scene.gmf"); 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,768,BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL); TController player=CreateController(); EntityType(player,1); SetBodyMass(player,1); SetBodyDamping(player,0.0); SetWorldGravity(Vec3(0,-20,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); strafe=KeyDown(KEY_D)-KeyDown(KEY_A); //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*3,strafe*3,jump,500.0f); //Update the world UpdateWorld(); //Position the camera TVec3 playerpos=EntityPosition(player); TVec3 camerapos=EntityPosition(cam); camerapos.Y=Curve(playerpos.Y+1.75,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 Link to comment Share on other sites More sharing options...
Marleys Ghost Posted February 18, 2010 Share Posted February 18, 2010 when you say moves off screen do you mean fall ? 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...
macklebee Posted February 18, 2010 Share Posted February 18, 2010 looks like you are loading a gmf and not a sbx file for your scene... you need to create a sbx file in the editor and load that using LoadScene() not LoadModel()... your player doesn't have anything to spawn on perhaps? unless maybe your scene.gmf is an actual scene? 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...
Elmar Posted February 18, 2010 Share Posted February 18, 2010 ok, i will again think about this code... Quote Link to comment Share on other sites More sharing options...
Marleys Ghost Posted February 18, 2010 Share Posted February 18, 2010 This code works: #include "engine.h" int main(int argc, char** argv) { Initialize(); //Create a graphics context Graphics(1280,768); //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 TModel scene=LoadModel("abstract::scene.gmf"); 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,768,BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL); TController player=CreateController(); EntityType(player,1); SetBodyDamping(player,0.0); SetBodyMass(player,1); SetWorldGravity(Vec3(0,-20,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); strafe=KeyDown(KEY_D)-KeyDown(KEY_A); //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*3,strafe*3,jump,500.0f); //Update the world UpdateWorld(); //Position the camera TVec3 playerpos=EntityPosition(player); TVec3 camerapos=EntityPosition(cam); camerapos.Y=Curve(playerpos.Y+1.75,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 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...
Elmar Posted February 19, 2010 Share Posted February 19, 2010 Thank you Quote Link to comment Share on other sites More sharing options...
Elmar Posted February 22, 2010 Share Posted February 22, 2010 when you say moves off screen do you mean fall ? yes Quote Link to comment Share on other sites More sharing options...
Marleys Ghost Posted February 22, 2010 Share Posted February 22, 2010 yes Is this still a problem? 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...
Elmar Posted February 22, 2010 Share Posted February 22, 2010 Is this still a problem? yes( Quote Link to comment Share on other sites More sharing options...
Marleys Ghost Posted February 22, 2010 Share Posted February 22, 2010 Have you tried moving the start position of the player controller up? are you still using the same .gmf scene? try: PostionEntity(player, Vec3(0.0, 5.0, 0.0)); 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...
Elmar Posted February 22, 2010 Share Posted February 22, 2010 Thank you Marleys Ghost, it's working now. How can regulate height of player? Quote Link to comment Share on other sites More sharing options...
Marleys Ghost Posted February 22, 2010 Share Posted February 22, 2010 regulate? 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...
Elmar Posted February 22, 2010 Share Posted February 22, 2010 to increase or to decrease Quote Link to comment Share on other sites More sharing options...
Marleys Ghost Posted February 22, 2010 Share Posted February 22, 2010 if you mean the starting height value for the position of the controler then you use PostionEntity as above the Vec3 is three values for that postion Vec3(x,y,z) ... the value for y (5.0 as above) sets the height. 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...
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.