How do i lock out a axis

 0 I am making game that is a top down 2-d game. I only want things to move in x and z, keeping anything from going to y. The problem is, i have the AI set on a waypoint system that uses rigidbodies, and some times when either myself, or other enemies collide with a enemy, it knocks them up or down in the y axis, making them impossible to shoot and kill yet they can still hit me, as they are scripted to aim in all 3 axis which is fine as it is universal and looks cool. So the bottom line is, how can i lock the objects in x and z and out of y. My thought was to have it keep resting it's y axis every frame in the update function, but i have no clue how to do that, and i fear it would either look jumpy, or make it lag a lot. more ▼ asked Feb 13 '10 at 07:39 PM xToxicInferno 485 ● 24 ● 28 ● 41 Ricardo 5.2k ● 20 ● 32 ● 96 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

 0 the best way is to use a configurable joint and lock the motion in y axis. you can do something like this in update with ``````transform.position.y=0; `````` but using joints is the correct way. more ▼ answered Feb 13 '10 at 08:18 PM Ashkan_gc 9.1k ● 33 ● 56 ● 117 Well i tried the joint, and all that does is make it so when i run into a enemy they fly up into the air, then back down to their usual height. I also locked Y motion and angular y motion. Feb 13 '10 at 08:26 PM xToxicInferno @Ashkan, one minor point - that's Javascript. In C# you can't assign to Y, you have to do: transform.position = new Vector3(x, 0, z) Jun 27 '10 at 06:28 PM Cyclops yes! in C# structs are paased by value so the reference of a vector3 will not be paased and you should get it's reference if you want to set it that way Jun 28 '10 at 03:09 AM Ashkan_gc add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

By Email:

Topics:

x5071
x1034
x322
x125

asked: Feb 13 '10 at 07:39 PM

Seen: 4507 times

Last Updated: Feb 15 '10 at 08:14 AM