Raul Posted March 29, 2010 Share Posted March 29, 2010 After doing the wiki tutorial and read one more time the article from Resources I thought I managed the Controller. But there are some problems: I made a little scene in the Editor. Testing with the fpsshooter script is ok. The character is correctly moving and sliding. The coll detection works fine with all the object. In my game the controller is jumping back when hitting a wall/fence and sometimes is going through them. This is my code: Create Player: PlayerController=CreateController(1.8,0.45,0.25,46); EntityType(PlayerController,1); SetBodyMass(PlayerController,10); Update Player: mx=Curve(MouseX()-GraphicsWidth()/2,mx,6); my=Curve(MouseY()-GraphicsHeight()/2,my,6); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); PlayerRotation.X=PlayerRotation.X + my/10.0; PlayerRotation.Y=PlayerRotation.Y - mx/10.0; PlayerMove=KeyDown(KEY_W)-KeyDown(KEY_S); PlayerStrafe=KeyDown(KEY_D)-KeyDown(KEY_A); if (KeyDown(KEY_LSHIFT)||KeyDown(KEY_RSHIFT)) { if (!ControllerAirborne(PlayerController)) { PlayerMove*=2.0; PlayerStrafe*=2.0; } } float PlayerJump=0.0; if (KeyHit(KEY_SPACE)) { if (!ControllerAirborne(PlayerController)) { PlayerJump=6.0; } } //Set controller input UpdateController(PlayerController,PlayerRotation.Y,PlayerMove*3,PlayerStrafe*3,PlayerJump,50); PlayerPosition=EntityPosition(PlayerController); PlayerHeadPosition=PlayerPosition; PlayerHeadPosition.Y = Curve(PlayerPosition.Y+1.8,PlayerHeadPosition.Y,4); PlayerHeadPosition=Vec3(PlayerPosition.X,PlayerHeadPosition.Y,PlayerPosition.Z); I alos tried the technique from the script (calculating the Strafe and Move using the Curve) but in that case the controller cannot be controlled. It simply goes trough objects Also I noticed a thing. My controller has 1.8 height. If set the PlayerHeadPosition.Y = PlayerPosition + 1.8, when in debug mode I saw the head (also the camera) is in the middle of the controller.. Quote i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64 rvlgames.com - my games RVL Games Facebook Page, YouTube Channel Blitzmax Link to comment Share on other sites More sharing options...
Rick Posted March 29, 2010 Share Posted March 29, 2010 I seem to recall that really skinny bodies, like your fence probably, don't always work correctly. Take the Curve() off when setting the position of the camera once and see if that helps. Quote Link to comment Share on other sites More sharing options...
Canardia Posted March 29, 2010 Share Posted March 29, 2010 You should not make walls and fences 0 mm thick, but as thick as they are in real. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Raul Posted March 29, 2010 Author Share Posted March 29, 2010 Rick: I removed the Curve and now its ok. Where is the problem in this case? I still want to use this function (Curve) Rick + Lumooja: The fence is taken from the Assets gallery. But the problem is that I have that "jumping back" also when hitting a wall which is not 0 mm Its true is not as bad as fence back but is still there. But why playing the editor is working fine and smooth and in my game sucks? p.s: The physic bodys are not 0 mm. Quote i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64 rvlgames.com - my games RVL Games Facebook Page, YouTube Channel Blitzmax Link to comment Share on other sites More sharing options...
Rick Posted March 29, 2010 Share Posted March 29, 2010 Why do you want to use that function for the height of the camera? Shouldn't that just be a certain value all the time? Do you have some gameplay thing in there where you want to change it's position with Curve()? Quote Link to comment Share on other sites More sharing options...
Canardia Posted March 29, 2010 Share Posted March 29, 2010 When you walk, your head bobs up and down using a curve (with a steeper curve when your leg hits the ground). Even in LCP1 we have that. I tried also swaying around the Z axis, but I got seasick, so I disabled it. And you don't rotate around the Z axis much at all when walking or running. The code is very simple, but it adds a great realism to any game (also 3 different footstep sounds): double walkadd=AppSpeed()*Length(GetBodyVelocity(game.scene.GetCurrentPlayer()->body)); walktimer+=walkadd; game.scene.GetCurrentPlayer()->eyeoffset.Y=Curve(1.0-0.4*sin(walktimer/500.0),game.scene.GetCurrentPlayer()->eyeoffset.Y,16); if(walktimer>125) { walktimer-=125; string i=""; i=49+(int)random(0,3); EmitSound(game.scene.GetCurrentPlayer()->body,LoadSound((str)string("abstract::walk"+i+".ogg").c_str())); } Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Raul Posted March 29, 2010 Author Share Posted March 29, 2010 @Rick: this function helped me when climbing up the stairs to not have a violent climbing.. @Lumooja: I will try right away your code. Quote i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64 rvlgames.com - my games RVL Games Facebook Page, YouTube Channel Blitzmax Link to comment Share on other sites More sharing options...
Rick Posted March 29, 2010 Share Posted March 29, 2010 I can't stand head bob in games. It always makes me sick. The fact that it's more real means very little to me in games where I have 5 people shooting at me from 20 yards and I'm getting hit but my "armor" helps me kill them. Quote Link to comment Share on other sites More sharing options...
Canardia Posted March 29, 2010 Share Posted March 29, 2010 It's pretty nice and doesn't make you sick when it's done right, and not unnaturally. And if someone still gets sick from it, then he's obviously not a good player as he can't stand some battle rumble So the advantage goes to the players who can stand more. It's the same with other game aspects too, I plan to make a game which is so scary that you can't play if you're too scared to play it It should have also 3D sounds, so you can't play it if you don't use headphones or have a decent 8.0 surround system. Games need a challenge to be fun, and lots of different challenges. I'm just playing C&C 95, and it's also damn challenging because the enemies zerg your base all the time, but that's what makes it fun. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Raul Posted March 29, 2010 Author Share Posted March 29, 2010 @Lumooja: your code is working (at least is an alternative to my simple Curve utilization) BUT no head bobs effect is present. I dont really want this effect but I am just afraid I am doing something wrong. Also another strange thing happen. I have a crate (an ammo box). If I set its collision to "Prop" when I go near it, it simply throw me away through walls for a long distance Quote i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64 rvlgames.com - my games RVL Games Facebook Page, YouTube Channel Blitzmax Link to comment Share on other sites More sharing options...
Canardia Posted March 29, 2010 Share Posted March 29, 2010 Make sure the player has mass 60, and the objects around 1-5 if you want to push them. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Raul Posted March 29, 2010 Author Share Posted March 29, 2010 You should see this... I changed the box mass to 5 from 10. Now when I hit it, sometimes is throwing me away, sometimes the box is jumping and flow in the air :| until I hit again. I have the gravitation set to 0, -20 , 0 p.s. The player has the mass 80 Quote i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64 rvlgames.com - my games RVL Games Facebook Page, YouTube Channel Blitzmax Link to comment Share on other sites More sharing options...
cassius Posted March 29, 2010 Share Posted March 29, 2010 I had this problem but found that it was because I had not updated the files in my project folder when i did the last update. Worked perfectly after I did so. Maybe not your problem, I don't know. 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...
Raul Posted March 29, 2010 Author Share Posted March 29, 2010 Nope. Its not that. I made a short video (sorry for the 50mb length but i have no converter..) showing my problem: www.rvlgames.com/bug.avi 1 Quote i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64 rvlgames.com - my games RVL Games Facebook Page, YouTube Channel Blitzmax Link to comment Share on other sites More sharing options...
cassius Posted March 29, 2010 Share Posted March 29, 2010 I found that a mass of 60 worked too well for me. a mass of 30 looks more natural in mt case rvl's description is exactly what I was getting. 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...
Raul Posted March 29, 2010 Author Share Posted March 29, 2010 with 30 is awful. I put 60. Its better but still my controller is shaking when hitting any object. Its shaking and from time to time is throwing me away ( Quote i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64 rvlgames.com - my games RVL Games Facebook Page, YouTube Channel Blitzmax Link to comment Share on other sites More sharing options...
Raul Posted March 29, 2010 Author Share Posted March 29, 2010 EDIT: same behavior. even if I use 30 or 60 or any number. Sometimes the Controller is throwing away, sometimes the objects are... Quote i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64 rvlgames.com - my games RVL Games Facebook Page, YouTube Channel Blitzmax Link to comment Share on other sites More sharing options...
cassius Posted March 29, 2010 Share Posted March 29, 2010 This line can also be relevant, particularly the iteration param. UpdateController(player, camrotation.Y, move * 5.5, strafe * 5.5, jump, 500,10) 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...
Raul Posted March 29, 2010 Author Share Posted March 29, 2010 Negative. Same thing. Imagine 2 cars coming with full speed one into another. This is happening with me and the objects when touch them. Quote i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64 rvlgames.com - my games RVL Games Facebook Page, YouTube Channel Blitzmax Link to comment Share on other sites More sharing options...
cassius Posted March 30, 2010 Share Posted March 30, 2010 My problem was that the objects hit by the controller fell toward the controller and when pushing against crates they flew behind the controller rather than in the direction pushed. Sometimes the controller would pass thru the level walls and fall out of the game. But as I said updating le solved the problem Actualy I was using the wrong updater at first, and not the latest one. 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...
Raul Posted March 30, 2010 Author Share Posted March 30, 2010 I see. Same behavior happens to me. Sometimes I fall out my map too. I have just one updater, mailed me by Josh 4 days ago. Quote i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64 rvlgames.com - my games RVL Games Facebook Page, YouTube Channel Blitzmax Link to comment Share on other sites More sharing options...
Raul Posted March 30, 2010 Author Share Posted March 30, 2010 I have uploaded 2 little movies about my problem. Also this is a simplified version of my code: PLEASE I really want to know where is the problem. I simply cannot make anything with this issues ( #include "engine.h" void InitLeadwerks() { Initialize(); SetAppTitle("Game"); Graphics(1024,768,0,0,GRAPHICS_BACKBUFFER+GRAPHICS_DEPTHBUFFER); RegisterAbstractPath("data"); SetTextureQuality(1); TFilter(1); AFilter(MaxAFilter()); } int main(int argc, char** argv) { InitLeadwerks(); CreateWorld(); //The Framework TFramework framework=CreateFramework(); TLayer myLayer = GetFrameworkLayer(0); TCamera frameworkCam=GetLayerCamera(myLayer); //Set Lua variable BP L=GetLuaState(); lua_pushobject(L,framework); lua_setglobal(L,"fw"); lua_pop(L,1); TController player=CreateController(1.8,0.4,0.5,45.01); EntityType(player,1); SetBodyMass(player,10); PositionEntity(player,Vec3(0,10,10)); DebugPhysics(1); // Setup map/scene LoadScene("abstract::map1.sbx"); Collisions(1, 1, 1); Collisions(1, 2, 1); HideMouse(); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); SetWorldGravity(Vec3(0,-20,0)); float move=0.0; float strafe=0.0; //Main loop while(!KeyHit(KEY_ESCAPE)) { move=KeyDown(KEY_W)-KeyDown(KEY_S); strafe=KeyDown(KEY_D)-KeyDown(KEY_A); UpdateController(player,0.0,move*3,strafe*3,0,40); //RotateEntity(frameworkCam,myPlayer.PlayerRotation); PositionEntity(frameworkCam,Vec3(0,5,0)); UpdateAppTime(); UpdateWorld(AppSpeed()) ; //PositionEntity(frameworkCam,myPlayer.PlayerHeadPosition); UpdateFramework(); RenderFramework(); Flip(0); } //Stop the engine and free the dll from memory Terminate(); return 0; } In the videos you can see how the objects are simply jumping around like crazy. This happens sometimes to my controller too. I tried all kind of mass settings. No result. Quote i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64 rvlgames.com - my games RVL Games Facebook Page, YouTube Channel Blitzmax Link to comment Share on other sites More sharing options...
Canardia Posted March 30, 2010 Share Posted March 30, 2010 These lines are not needed and may cause wierd physics behavior: UpdateAppTime(); UpdateWorld(AppSpeed()) ; UpdateFramework does those commands already. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Josh Posted March 30, 2010 Share Posted March 30, 2010 The only time I have experienced a controller being "thrown" with great force was when the physics geometry had some one-sided surfaces it was moving into from behind. If you want help, please post an example we can run that demonstrates your problem. Otherwise we are just speculating about what it might be. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Raul Posted March 30, 2010 Author Share Posted March 30, 2010 If their is a supra natural force somewhere in this Universe then: THAT FORCE BLESS you Lumooja Thanks you to all for helping me. You to Josh Quote i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64 rvlgames.com - my games RVL Games Facebook Page, YouTube Channel Blitzmax 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.