Sliding Door Controlled by Mouse?

I’m trying to have a sliding door in my game that the player can use the mouse to drag open. I tried using the script in this thread, but it ended up getting dragged all over the level, not just along a single axis (I locked X and z transformations in the physics panel, and it’s locked along those axes if I try to move it normally(like by pushing against it), but once I try moving it with the mouse, it just drags like a normal object. I can pull it off the doorframe like it’s not attatched, the constraints don’t work. Does anyone know how I could fix this?

I have a demo in resources for making a rigid body joint via a ray, and you can then remove tho joint by clicking again,

It would work perfectly ,however until HG1s new patch the rigid body joints crashed blender randomly,

2.73a? I think is the most recent build and it should be fixed.

Alternatively, you use the mouse movement to apply force against objects,

Exposing the mouse movement as a property would be step 1,

Check out Easy Mouse, in resources

Tada !

you can use this for a lot more then just doors :smiley:

left click on the cube, move mouse, release

Clicking stores the localized offset, then releasing gets that localized offset at the release point,

The end localized offset is then use as a target for getVectTo, which is then used to apply force to the object. I think making it get stronger the further you stretch the mouse move would be good, also another version for push/pull would be good.

Attachments

MouseThrow.blend (422 KB)

Do I need all the python scripts in that file? I’m just trying to use the mouse to move it along an axis.

Also, these don’t really help me at all. I’m trying to move the object along just one axis.

One script = get localized hit position, start Timer
Second script = triggered on release mouse, apply force reset timer.
Third script = Mouselook based on x, y
ForceLean.py = generate x y from mouse.

As for the axis, just use a rigid body joint like I showed in the video.

You can reuse the same system to make doors that lift up or?

Three scripts (Mouselook and movement are the two you don’t need to worry about)
The script that you need is called “Door”. It’s like 25 lines long.

We get the mouse position and use the x value with the sensitivity to move the door
FirstPersonOpenDoor.blend (487 KB)

Dude, that’s awesome, thank you. I was trying to recode the mouselook script, but this is much easier, and more efficient than I could have done. Thanks!