# How to constraint the motion of a rigid body to the xz plane?

 0 Hi Guys, I am working on a game similar to air hockey. I want to restrict the movement of puck to xz axis. Currently when i hit the puck it travels in y axis with some units too. but i dont want it to leave the base ever. plz help.................. more ▼ asked Jan 06 '11 at 09:41 AM user-8010 (google) 1 ● 3 ● 3 ● 6 SisterKy 2.4k ● 33 ● 41 ● 59 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

 0 you could use Rigidbody.constraints if you are using a rigidbody... Unity could not find RigidbodyConstraints when i tried it even though its there on unity site. Maybe you will have better luck in findng out how to use it. If you do use it, do share... you could use: rigidbody.constraints = RigidbodyConstraints.FreezePositionY; more ▼ answered Feb 26 '11 at 07:20 AM Antzy 11 ● 1 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users
 0 You could add the following to the Update function in the script attached to your puck: `transform.position.y = 0;` more ▼ answered Jan 06 '11 at 11:00 AM cjmarsh 373 ● 2 ● 9 Hi,Thnx fr the reply... but it still moves a bit in y position... Actually I have 2 pucks.. I hit 1 puck with other using power. But in some cases, what happens is puck 1 goes over the puck 2.... ? What to do plz help bro Jan 06 '11 at 11:11 AM user-8010 (google) When you say 'goes over' do you mean it goes up and over or it just goes 'through' the other puck? Jan 06 '11 at 11:30 AM Meltdown It goes up and over, not thru... Jan 06 '11 at 11:42 AM user-8010 (google) You could try Rigidbody.useGravity = false; on each puck. This should get rid of the force being applied to them in the y direction. Jan 06 '11 at 11:45 AM cjmarsh did that but no use... Its happening at random. Sometimes the puck travels in y and sometimes it doesnt...plz help Jan 07 '11 at 05:34 AM user-8010 (google) add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users
 0 the "dirty" update version works, but did anybody figure out how these constraints actually work? more ▼ answered Oct 24 '11 at 05:21 PM Somian 206 ● 35 ● 46 ● 52 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

By Email:

Topics:

x322
x134
x32

asked: Jan 06 '11 at 09:41 AM

Seen: 2446 times

Last Updated: Feb 08 '12 at 02:01 PM