Creating a sliding door with Rube

General discussion about the R.U.B.E editor
Post Reply
Coder_for_Life22
Posts: 6
Joined: Sun Oct 13, 2013 1:17 am

Creating a sliding door with Rube

Post by Coder_for_Life22 »

Could someone explain how to create a sliding door with rube?
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Creating a sliding door with Rube

Post by iforce2d »

This is probably a good place to start:
RUBE editor tutorial 13/17 - Prismatic joints
Coder_for_Life22
Posts: 6
Joined: Sun Oct 13, 2013 1:17 am

Re: Creating a sliding door with Rube

Post by Coder_for_Life22 »

Yes, i watched this.

The problem is, i know how to enable the motor for going up or down, but i am not sure how to make it go up and down.
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Creating a sliding door with Rube

Post by iforce2d »

It's a good idea to mention these things when asking a question so that people don't waste their time (and yours) giving you suggestions for things that you already know:
1. What are you trying to do?
2. What have you tried already?
3. What went wrong?

Three settings work together to make a prismatic joint move. As long as you set the joint to be enabled, set the max force to a value high enough to move the bodies involved, and give it a non-zero speed, it should move. In your program, you can change the speed at runtime to make it move in different directions.
Coder_for_Life22
Posts: 6
Joined: Sun Oct 13, 2013 1:17 am

Re: Creating a sliding door with Rube

Post by Coder_for_Life22 »

Ok,

Here is the problem.

I am trying to create sliding door(opening and closing).

I have watched the video on prismatic joints and i have door closing.

I just cant figure out how to get it to open, then close, open, then close.

Help on creating this would be greatly appreciated.
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Creating a sliding door with Rube

Post by iforce2d »

Well as I mentioned already, you can change the speed at runtime to make it move in different directions. Did you try that?

For example:

Code: Select all

//moves joint one way
doorJoint->SetMotorSpeed( 1 );

//moves joint the other way
doorJoint->SetMotorSpeed( -1 );
Coder_for_Life22
Posts: 6
Joined: Sun Oct 13, 2013 1:17 am

Re: Creating a sliding door with Rube

Post by Coder_for_Life22 »

Awesome!

Works perfectly.
Post Reply