Non-dynamic box collision detection

i’ve got a box that can be “pushed” around by my character. However, when the box gets pushed while it’s up against a wall it just goes through the wall. How can i stop it from going through the wall? I’m using DLoc to move the box, and i’ve tried a touch sensor and a collision sensor, the both don’t work. Any ideas?

Pooba

hrm…you could make it dynamic, and then “Rigid Body”…you would have to add a negative(whatever your gravity is) force on an always sensor…but then again, its still dynamic and you would have to deal with the frustrating bounding sphere…hmm…you could do this and have it still un-dynamic’d…

1.) whatever the DLoc force is, (lets say its 5 for examples sake…)
2.) you would add a -5 DLoc to a “near” sensor.
3.) the near sensor and negative force would be placed onto the walls.
4.) and finally make sure the near parameters are fairly close to the wall, so the illusion of it actually stopping is believable…

im not sure if that will work or not…ive never tried it…but as long as the character is pressing on the box, the box will press back with an exact but negative force…i think that might work…im not sure tho…

umm, don’t use dloc to move the box

or, if there is a python controller attached to the box, have it look at the obj.reactionForce() value to determine if the box has run into something.

I can’t have it be dynamic, my character has to be able to climb up onto it. Both LinV and Force don’t work on the box unless it’s dynamic, so DLoc is my only option.

Pooba

why?

why can’t the box have collision faces (for the player to collide with), and the sphere bounds like inside of the box where the player can’t touch it much?

If you have a limited area in which to push the box, say a big rectangle, you could check for that:

if push_east and posx < east_border:
dlocx = 10
if push_west and posx > west_border:
dlocx = -10
if push_south and posy > south_border:
.
.
.

Try adding a ray sensor with inverted output, and attaching it to the controller.
Here’s an example that I just happened to have laying around.
http://www.digidreamer.org/upload/Feb14_non_dynamic.blend

This could probably work with python too. With a few changes of course.

i’ve got a mini-version of my level and script. I tried but couldn’t get the ray thing to work, so, if anybody can figure it out i’d be VERY thankful.

www.gratisweb.com/pooba/movingbox.blend

Arrows to move, space to shoot the shot that moves the box.

The way the script works is that each side is parented to a main empty that moves around. A script is always being run that moves the box, and it checks to see if the property loop is greater than 0. If it is, then it moves it in a certain direction. The loop property gets set by another script that is triggered by a collision sensor. You’ll see if you download the file.

Thanks!!

Pooba

I tried, but it didn’t turn out so great.

http://www.digidreamer.org/upload/Feb15_movingbox.blend

It works ok sometimes, but it’s far from perfect.
Basically I only added a few things. I added four ray sensors to the empty, one pointing in each direction. I wired them to all of the MOVINGBOX python scripts, and added a “and” expression to each of the if statements so the box will only move if the ray is not being fired. (I inverted their outputs so they will fire when they aren’t sensing something)
It really doesn’t work as well as I’d like, but it’s a start. There’s probably a better way to do it. One that isn’t so buggy. I just can’t see it.

Thanks, it works some of the time, but not always. I’ll work with it a bit more.

Where’d you get the number 3.6 for the ray sensor’s distance?

Pooba

Sorry, I still can’t get it to work. And to answer your question: 3.7 just worked the best.

I CAN’T WAIT FOR SOLID!!! :smiley:

z3r0 d is right that should work. Adjust the size of the bounding sphere so that its just inside the faces of the box. Turn collisions on for the faces, and set the box to dynamic but not rigid body. That should work fine, allowing the box to be a dynamic object but the player can still walk on its faces because the player will collide with them before he collides with the bounding sphere. I’m sure that will work.

Keith. 8)

Now i feel stupid :expressionless: , such a simple answer, i should have thought of it. I didn’t fully understand z3ro d’s suggestion, so i didn’t really consider it :expressionless: . Now it should work fine, thanks guys!

Pooba

z3r0 d is right that should work. Adjust the size of the bounding sphere so that its just inside the faces of the box. Turn collisions on for the faces, and set the box to dynamic but not rigid body. That should work fine, allowing the box to be a dynamic object but the player can still walk on its faces because the player will collide with them before he collides with the bounding sphere. I’m sure that will work.

Keith. 8)[/quote]

Nope. At least, not in 2.25. Setting an object to dynamic makes all its faces no longer be considered for collisions. Other objects will only be able to collide against it’s bounding sphere.

The solution I used is to parent a non-dynamic mesh to the dynamic object. Other obejcts will collide against the non-dynamic mesh with per-face accuracy, instead of the sphere of the dynamic object.

Yeah, that’s what i did wiseman, and it works perfectly. Thanks again everybody who helped.

Pooba

Hang on I just thought of a problem with that method. If you parent a big non-dynamic box box to a smaller dynamic empty you will be able to walk on it okay, but how do you push it around? the dynamic empty will never experience a collision because the player will always collide with the face of the box first, so it will never move. Pooba you said it works perfectly, but how? When the player collides with the box it won’t move. Are you using python to make the dynamic empty move instead? :-?

Keith. 8)

have you tried making an action of the box moving so that when the player either touches or come close to it the box moves, and you could do somthing thats close to that for climbing on to the box. I hope this helps you. :smiley:

Hang on I just thought of a problem with that method. If you parent a big non-dynamic box box to a smaller dynamic empty you will be able to walk on it okay, but how do you push it around? the dynamic empty will never experience a collision because the player will always collide with the face of the box first, so it will never move. Pooba you said it works perfectly, but how? When the player collides with the box it won’t move. Are you using python to make the dynamic empty move instead? :-?

Keith. 8) [/quote]

Just parent an invisible mesh to the character, that’s big enough to reach the bounding sphere of the box’s dynamic empty.

Keep blendin’ 8)