YouGroove Posted February 6, 2015 Share Posted February 6, 2015 Hi, I have some 2.5D prorotype, i use PhysicsSetPosition. The problem is the charcater have a box collision and moving it in direction to a cube it will go trhought that cube volume, and we should expect collision to prevent that. How to test : - create a new project - dezip files - place 25D.lua in "Scripts/objects/Player" folder - place 25D.map in "Map" folder Use Q and D to move the character, and keep Q down continuously to make the character going left to the big cube , it will go inside and move throught the left big cube after some second. 25D.zip Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Josh Posted February 6, 2015 Share Posted February 6, 2015 This is pretty much how I would expect it to act. You're applying very very large forces to the body. Is there a reason you're not using the character controller for this? 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...
YouGroove Posted February 6, 2015 Author Share Posted February 6, 2015 Yes , it was to keep constraint axis, i mean moving objects only on X and Y like many 2.5 D games. I didnt' know it worked using big forces. So i see two solutions : - using some raycast at diffrent height from player center to direction it is facing and stop calling PhysicsSetposition if the ray hits something and player is near - stop calling PhysicsSetPosition if character is in collision with Level geometry Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Josh Posted February 6, 2015 Share Posted February 6, 2015 I would use the player controller and just call SetInput to move it back towards the center if the z value is non-zero. You can probably even just call entity->SetPosition(x,y,0.0) safely since the player controller doesn't use "real" physics. 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...
YouGroove Posted February 6, 2015 Author Share Posted February 6, 2015 The problem with character controller it will always go a little front or back in Z , while a real XY constraint system there is not possible to have any move on Z. But i agree using SetPosition could be a way. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Josh Posted February 6, 2015 Share Posted February 6, 2015 You can also manually position the visual mesh at the XY position of the character, with Z set to 0. 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...
YouGroove Posted February 7, 2015 Author Share Posted February 7, 2015 Using a character controller , if it collides with a barrel while walking , it will go on the sides with Z values to avoid the obstacle and continue forward on X. While we want the character physics to always stay at Z=0 and push the barrel that itself could not move in Z axis and also stay on Z=0. So the only way is PhysicsSetPosition() combined with Raycast or collision detection with obstacle to stop moving. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Josh Posted February 10, 2015 Share Posted February 10, 2015 Maybe your barrel should be set up on a hinge joint or something so that it only rotates around the z axis. I would think for 2D physics you would want this behavior anyways. Hmmm, a hinge joint that only affected rotation would be very useful. We actually have something like that already in Newton. 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...
YouGroove Posted February 10, 2015 Author Share Posted February 10, 2015 Maybe your barrel should be set up on a hinge joint or something so that it only rotates around the z axis. I'm not sure as the barrel should be able to be pushed or thrown anywhere on space, it would only not move on 2 axis. And workflow would be longer creating physic joints for every object that could be dynamic. I just found the solution that works for 2.5D physics constraint on Z for physic objects function Script:UpdateWorld() local vel = self.entity:GetVelocity(true) if vel.z > 0 or vel.z < 0 then vel.z = 0 self.entity:SetVelocity(vel,true) end end Some 2.5D character controller could be using SetVelocity on X , combined with AddForce() for jumping, and perhaps some collision or ray detection for special cases. 2 Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Josh Posted February 10, 2015 Share Posted February 10, 2015 I'm not sure as the barrel should be able to be pushed or thrown anywhere on space, it would only not move on 2 axis. That's what 2D physics is. I think for puzzles this would be the desired behavior. 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...
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.