gamecreator Posted August 3, 2011 Share Posted August 3, 2011 I've come to the understanding that LE2 doesn't support body forces for character controllers. It would be really nice if LE3 supported this (even better if 2 did also!). It's useful for any type of game. Also, I'm making a platformer a little bit like Trine. It would be nice to limit body and character controller movement to a 2D plane with a single function, like RestrainBodyMovement(player1,Vec3(1,1,0)); Thanks! Bonus points if RestrainBodyMovement(player1,Vec3(.5,2,0)); makes movement half speed on the X axis, double speed on the Y axis and 0 on the Z axis. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted August 4, 2011 Share Posted August 4, 2011 I think this is a standard thing in Physics engines ? A simple Axis constraint i fact ! It is an example on a 2D platform Unity tutorial unsig an axe constraint, it can happen anything : physic explosion, object rotation around any axe, the objects can't move on the axe constraint , perhaps you could check it out to be inspired or to see if Newton don't already have that ? But i agree it can be a usefull feature for making any 2.5D style games playing in a screen plane and using 3D objects like 2.5D platformers , to puzzle games etc ... Quote Stop toying and make games Link to comment Share on other sites More sharing options...
YouGroove Posted August 4, 2011 Share Posted August 4, 2011 I posted a solution used by games in industry and that works great ! Games like Pandemonium, Klonoa, ViewTifull Joe, Killer Seven etc .... I re post here the solution i posted in the blog site right bar : Another idea ? Simply create a Path along your level telling character, NPC , bullets, cars etc ... to follow it forward or backward ! Like Pandemonium PS1 game ! Just make a path for player, NPC etc ... to follow and make them follow it forward or backward without physics. If you really need physics, perhaps make invisible walls meshes for collision (God of War game solution on PS2 used that type of collision : invisible meshes created uppon the level on Maya software) ! Quote Stop toying and make games Link to comment Share on other sites More sharing options...
gamecreator Posted August 4, 2011 Author Share Posted August 4, 2011 Thanks YouGroove. I'm definitely not out of workaround options. Worst case scenario, if the walls around the player don't end up working out, I may simply remove the physics altogether and do them myself, using another library called PMask. It's much more of a pain but it also gives me full control. But yes, this really should be in the engine, in my opinion. Quote Link to comment Share on other sites More sharing options...
Josh Posted August 4, 2011 Share Posted August 4, 2011 For character controllers, it's actually perfectly fine to constrain them yourself by just setting the Z position to 0. It won't hurt anything. I don't like having inconsistency like that, but if you want a solution right now, it will work. Don't do this with regular physics bodies. 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...
Rick Posted August 4, 2011 Share Posted August 4, 2011 Like via PositionEntity()? I thought calling those commands on bodies causes collision issues? Quote Link to comment Share on other sites More sharing options...
Josh Posted August 4, 2011 Share Posted August 4, 2011 Yes, but the character controller isn't really a physics body. It uses my own simple physics, so I can control it completely. 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...
Rekindled Phoenix Posted August 5, 2011 Share Posted August 5, 2011 I've run into horrible issues with the current version and axis restraints, physics bodies in particular. I either have to create several invisible walls that limit movement, or use a curve algorithm that adjusts the position every frame. This is a must! +1 Quote Link to comment Share on other sites More sharing options...
Josh Posted August 5, 2011 Share Posted August 5, 2011 I will strongly consider this, since 2.5d games will be more common in L3. You can however use CalcBodyVelocity() to calculate what force you need to apply to keep bodies on a flat plane. 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...
gamecreator Posted August 5, 2011 Author Share Posted August 5, 2011 PositionEntity doesn't seem to work on the character controller. I originally posted a thread here but I thought I'd post my code here as well, in case you have any ideas. Very simple code. No assets needed. Copy it right into a new project if you'd like. #include "engine.h" #pragma warning(disable:58) int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ) { if(!Initialize()) return 1; RegisterAbstractPath("D:/Programming/Leadwerks Engine SDK"); // Set graphics mode if(!Graphics(640,480)) { MessageBoxA( 0,"Failed to set graphics mode.","Error",0); return 1; } // Create framework object and set it to a global object so other scripts can access it TFramework fw = CreateFramework(); if(fw==NULL) { MessageBoxA(0,"Failed to initialize engine.","Error",0); return 1; } // Set Lua framework object SetGlobalObject("fw",fw); // Set Lua framework variable BP lua=GetLuaState(); lua_pushobject(lua,fw); lua_setglobal(lua,"fw"); lua_pop(lua,1); // Get framework main camera TCamera camera = GetLayerCamera(GetFrameworkLayer(0)); PositionEntity(camera,Vec3(13,5,-12)); RotateEntity(camera,Vec3(15,0,0)); TLight light=CreateDirectionalLight(); RotateEntity(light,Vec3(45,45,45)); SetWorldGravity(Vec3(0,-80,0)); // PLAYER TController player=CreateController(1.8,0.4,0.5,45.01); EntityType(player,1); SetBodyMass(player,10); PositionEntity(player,Vec3(0,1,0)); float move=0.0; float strafe=0.0; // GROUND TEntity ground=CreateBodyBox(40,1,1,0); SetBodyMass(ground,0); EntityType(ground,2); Collisions(1,2,true); DebugPhysics(1); SetStats(2); while(!KeyHit(KEY_ESCAPE)) { TVec3 pos; move=KeyDown(KEY_RIGHT)-KeyDown(KEY_LEFT); pos=EntityPosition(player,1); PositionEntity(camera,Vec3(pos.X,pos.Y+4,-15)); float jump=0.0; if (KeyHit(KEY_SPACE)) { if (!ControllerAirborne(player)) { jump=30.0; } } move*=10; UpdateController(player,270.0,move,0.0,jump,50); pos=EntityPosition(player,1); // PositionEntity(player,Vec3(pos.X,pos.Y,0),1); UpdateFramework(); RenderFramework(); DrawText(0,300,"player.Z: %f",pos.Z); Flip(0); } return Terminate(); } With the PositionEntity line commented, the character controller works fine. With it uncommented, it seems to break (the character controller becomes almost entirely non-responsive). But please let me know if I'm doing something wrong. Quote 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.