|
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.
(comments are locked)
|
|
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
but using joints is the correct way. 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
(comments are locked)
|
