tjheldna Posted April 27, 2013 Share Posted April 27, 2013 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! Quote Link to comment Share on other sites More sharing options...
Mumbles Posted April 28, 2013 Share Posted April 28, 2013 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. Quote LE Version: 2.50 (Eventually) Link to comment Share on other sites More sharing options...
Rick Posted April 28, 2013 Share Posted April 28, 2013 Possibly put a physics "wall" on both sides of the player throughout the entire map with just enough room for the player to move between it? Quote Link to comment Share on other sites More sharing options...
tjheldna Posted April 28, 2013 Author Share Posted April 28, 2013 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. Quote Link to comment Share on other sites More sharing options...
Daimour Posted April 28, 2013 Share Posted April 28, 2013 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. Quote Link to comment Share on other sites More sharing options...
Daimour Posted April 29, 2013 Share Posted April 29, 2013 I tested this case in LE2. And it works fine with GetVelosity()/SetVelocity() instead of GetPosition()/SetPosition(). But I can't see SetPosition() in LE3 documentation. Quote Link to comment Share on other sites More sharing options...
Admin Posted April 29, 2013 Share Posted April 29, 2013 Entity::PhysicsSetPosition() http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/entity/entityphysicssetposition-r190 Quote Link to comment Share on other sites More sharing options...
tjheldna Posted April 30, 2013 Author Share Posted April 30, 2013 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. Quote Link to comment Share on other sites More sharing options...
Admin Posted April 30, 2013 Share Posted April 30, 2013 Entity::PhysicsSetPosition uses forces to set the position without breaking the physics simulation. Quote Link to comment Share on other sites More sharing options...
tjheldna Posted May 20, 2013 Author Share Posted May 20, 2013 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! Quote Link to comment Share on other sites More sharing options...
Aily Posted May 20, 2013 Share Posted May 20, 2013 Seems like everyone wants Blitz3D collisions system Quote "Better" is big enemy of "good" Link to comment Share on other sites More sharing options...
Josh Posted May 20, 2013 Share Posted May 20, 2013 Use the SetInput function to steer the character towards the 0 z position. 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...
tjheldna Posted May 20, 2013 Author Share Posted May 20, 2013 Think I got it or at least part of it.... Does this look correct for getting the direction? Vec3 pos = GetTargetEntity()->GetPosition(); Vec3 pos2; float dirx = pos2.z - pos.z; yaw = Math::ATan2(dirx, movement.z) - 180; Quote Link to comment Share on other sites More sharing options...
gamecreator Posted May 20, 2013 Share Posted May 20, 2013 Seems like everyone wants Blitz3D collisions system I'm trying to use Box2D to make a 2D platformer but it has its own issues and you have to keep "hacking" it to do what you want. I've yet to find a solid physics solution which includes full control over character controllers. Quote Link to comment Share on other sites More sharing options...
Rick Posted May 20, 2013 Share Posted May 20, 2013 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. Quote Link to comment Share on other sites More sharing options...
tjheldna Posted May 20, 2013 Author Share Posted May 20, 2013 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. Quote Link to comment Share on other sites More sharing options...
Josh Posted May 20, 2013 Share Posted May 20, 2013 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. 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...
steeleb Posted May 21, 2013 Share Posted May 21, 2013 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*. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted May 21, 2013 Share Posted May 21, 2013 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 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. Quote Stop toying and make games 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.