Lock a certain axis...?

I’ve searched everywhere, and I couldn’t find a method that works.
I’ve got a square (not a cube, a square!!) and when you jump on someone’s head, he sorta falls off the level.

The ground plane is pretty thin (its 3D) and when he jumps on the head, it pushes him towards/back of the screen and he plummets :0

How can I lock that axis (x) and be sure this doesn’t happen EVER AGAIN!!?? :confused:

Thank you!

There is a Constraint actuator you can use. Set it to Limit Location on X axis to the desired value (I’m assuming 0.00).

Also, if the physics system makes this not work for you, then put a Location F-Curve on the X-axis only and run an Always hooked to an Action actuator to constantly run the animation (keeping the square locked in that X position).

If neither of those things work, you can always run a script that manually sets the X position of the square. You would tell it to use the current Y and Z positions, but override the X (with 0.00 or whatever).

(If none of these things work, I’m sure there are at least 2 or 3 other methods.)

Can you tell me more about the animation method? Whats the “F-Curve”?

An F-Curve is an animation curve which is built from keyframes (previously called an IPO in Blender 2.49 and earlier). You can view them in the Curve editor.

The important point is that you want the animation to be on the X axis only. Bring up the Transform properties panel by pressing “N” over the 3D viewport. Right-click the X Location value, and choose “Insert Single Keyframe”. Make sure you choose “Single Keyframe” or you will animate all 3 axes. You can right-click and delete keyframes if you make a mistake.

Once you’ve done that, add a property to you square and name it “frame”, set it to “1”. Hook an Always to an Action Actuator and select the F-Curve you just made. Set the Actuator to “Property” mode, and use the “frame” property.

If you follow those directions precisely, it should hold your player in one place on the X axis only.

did EVERYTHING as instructed…
mind takin’ a look at it? :’(

Attachments

The Game ;’(.blend (516 KB)

Well, you had a couple of problems with your setup. First, you skipped the step where I said “select the F-Curve you just made”. You need to tell an Action actuator which action you want to run. Second, you want to lock the player to the local X-axis, but it’s really the global Y-axis. Location F-Curves of unparented objects are relative to the global axis, so you would have needed to animate the Y-axis. Third, you did not turn on “Positive Pulse Mode” (TRUE Level Triggering) on your Always Sensor, so it was only firing once, not repeatedly.

That said, the F-Curve method was unreliable. I have set up your file so that the yellow player uses the Constraint Actuator method (all Logic Bricks), and the blue player uses the Python script method. Both of these work well. You can decide for yourself which you prefer to use. (It probably makes no difference to the game’s performance which you pick.)

The Game ;-).blend (101 KB)

:smiley:
You’re awesome, and I noticed you switched the ;’( face to a happy one xD

Thank you very much for taking the time out of your day to help.