Jump to content

Body Forces on Character Controllers & 2D Constraint

Recommended Posts

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






Bonus points if



makes movement half speed on the X axis, double speed on the Y axis and 0 on the Z axis. :rolleyes:

Share this post

Link to post

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 ...

Share this post

Link to post

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) !

Share this post

Link to post

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.

Share this post

Link to post

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.

Share this post

Link to post

Like via PositionEntity()? I thought calling those commands on bodies causes collision issues?

Share this post

Link to post

Yes, but the character controller isn't really a physics body. It uses my own simple physics, so I can control it completely.

Share this post

Link to post

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! ;)



Share this post

Link to post

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.

Share this post

Link to post

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
	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();
	MessageBoxA(0,"Failed to initialize engine.","Error",0);
	return 1;

// Set Lua framework object

// Set Lua framework variable
BP lua=GetLuaState();

// Get framework main camera
TCamera camera = GetLayerCamera(GetFrameworkLayer(0));

TLight light=CreateDirectionalLight();


TController player=CreateController(1.8,0.4,0.5,45.01);

float move=0.0;
float strafe=0.0;

TEntity ground=CreateBodyBox(40,1,1,0);




	TVec3 pos;


	float jump=0.0;
	if (KeyHit(KEY_SPACE)) {
		if (!ControllerAirborne(player)) {



//		PositionEntity(player,Vec3(pos.X,pos.Y,0),1);


	DrawText(0,300,"player.Z: %f",pos.Z);


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.

Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...