Jump to content

physic cube entering physic volume


YouGroove
 Share

Recommended Posts

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.

 

2_Dbug.jpg

 

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

Stop toying and make games

Link to comment
Share on other sites

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?

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

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

Stop toying and make games

Link to comment
Share on other sites

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.

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

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.

Stop toying and make games

Link to comment
Share on other sites

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.

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

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

 

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.

  • Upvote 2

Stop toying and make games

Link to comment
Share on other sites

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.

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

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