Jump to content

Restrict physics axis


tjheldna
 Share

Recommended Posts

Hi All,

 

Is there a way to restrict a physics object to two update on two axis only?

 

I've tried in the physics hook....

 

 

Vec3 pos = entity->GetPosition(true);

pos.z = 0.0F;

entity->SetPosition(pos, true);

 

The objects physics position does not move at all after that. If I can't get this essential detail working it's game over for me =(.

 

Thanks in advance!

trindieprod.png?dl=0spacer.png?dl=0steam-icon.png?dl=0twitter-icon.png?dl=0spacer.png?dl=0
Link to comment
Share on other sites

In raw Newton, you attach a custom 6DOF joint to the body you want to restrict (and specify no parent body), and set that joint's "linear limits" for the axis in question to 0. So for top down views only, with no jumping, set the min and max linear limits for the Y axis to 0. Now it can move forward/backward and left/right, but not up/down.

 

BUT... I don't think LE 3 exposes the custom joints part of the Newton library (and I know for sure LE 2 doesn't), so sorry, but I don't think you can do it.

LE Version: 2.50 (Eventually)

Link to comment
Share on other sites

Thanks for the reply's guys. Damn I'm doing a 2d side scroller in 3D and was fine till I started adding a few enemies etc and things are starting to get bumped around.

 

@Rick I thought of doing that, but was really hoping for a code solution. I think at least for now it may have to do, **** I'm even thinking I may have to change engines for this project if it can't be done, which I really don't want to do.

trindieprod.png?dl=0spacer.png?dl=0steam-icon.png?dl=0twitter-icon.png?dl=0spacer.png?dl=0
Link to comment
Share on other sites

I may assume that both physics driven update and entity->SetPosition() are producing new position in world->Update() simultaneously. So they concurrent to each other and SetPosition() wins.

 

I don't know if it will be suitable for you, but you can try call entity->SetPosition() not every frame, but every second frame. Thus first world->Update() will move entity by physics and the second one will execute SetPosition().

 

Or you can try to call world->Update() twice in one frame for that purpose. And use SetPosition() between them. But I'm afraid it will eat a lot of FPS.

Link to comment
Share on other sites

Hi Daimour,

 

Sorry I couldn't respond yesterday, had a very busy day and today will be about the same. Thanks for looking into this for me, it is much appreciated.

 

I did try using SetPosition every second loop however it seemed to noticeably pause the physics. I'm looking forward to see what Setting the Velocity will do, but I'm going to have to do it tomorrow night!

 

 

I also tried using to boxes either side of the game play which did work, however it makes level editing a bit harder and viewing the level physics harder too.

trindieprod.png?dl=0spacer.png?dl=0steam-icon.png?dl=0twitter-icon.png?dl=0spacer.png?dl=0
Link to comment
Share on other sites

  • 3 weeks later...

Hi All, it's been a while since I've been able to update on this. I've had great success using PhysicsSetPosition on physics objects, however it seems to have no effect on a character controller. Any ideas of what to do there or what's causing it to ignore?

 

Cheers Again!

trindieprod.png?dl=0spacer.png?dl=0steam-icon.png?dl=0twitter-icon.png?dl=0spacer.png?dl=0
Link to comment
Share on other sites

Could make the game style like double dragon where you have a little room in the z direction to play with. Then the invisible colliders would work just fine.

 

Also, just checked out double dragon again. The opening scene has a guy punching a girl in the stomach and taking her away. Nothing like a little domestic violence on women to start a game. I totally forgot about that.

Link to comment
Share on other sites

Ahh gone are the days where the only plot is to rescue your girlfriend! Yeah that is an option, but not optimal

 

The code above does make the character always go to the 0 z axis however he can be pushed off a little. He will also face the direction he is going which I can't have. I'm stumped, maybe setting collision boxes either side of the player is currently the only way?

 

I like box2d, I'm using it for an ios project using cocos2d-x. Sound's like a good solution but I don't think i'm smart enough to plug that in to LE though.

trindieprod.png?dl=0spacer.png?dl=0steam-icon.png?dl=0twitter-icon.png?dl=0spacer.png?dl=0
Link to comment
Share on other sites

I would manually set the model's rotation before a call to World->Render() so you can have them face wherever you like. You shouldn't need to mess around with the angle, just use the strafe value to move left and right, and use the move value to align him to the XY plane.

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

I would manually set the model's rotation before a call to World->Render() so you can have them face wherever you like. You shouldn't need to mess around with the angle, just use the strafe value to move left and right, and use the move value to align him to the XY plane.

 

I have been using the AlignToVector method to face my model in the appropriate direction, is there any advantage to using SetRotation, or SetInput over AlignToVector? I use the AlignToVector method because it can interpolate between rotations. However, if the angle is large, the model rotation is sometimes *jittery*.

Link to comment
Share on other sites

Also, just checked out double dragon again. The opening scene has a guy punching a girl in the stomach and taking her away. Nothing like a little domestic violence on women to start a game. I totally forgot about that

Yes this is the way to motivate the player to beat up the bad people laugh.png

 

For 2.5D , the best could be some to use setPosition, and simple collision boxes, and manage, X and Z movement yourself wihtout using physics.

They are many games using their own physics on racing car or platform and it works well, they even add more personnalisation like faster fall down than jump, or more pronounced streering.

Stop toying and make games

Link to comment
Share on other sites

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.

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

 Share

×
×
  • Create New...