I'm still trying to get the fundamentals of the blender game engine down, but for now I have this:

shopping cart

The camera's position is controlled with W A S D, and the camera rotates to where the mouse is, like in Minecraft.

What I want to happen is when the player presses W, the cart moves forward, along with person while maintaining the same distance away. I thought about just copying the W to move forward from the camera to the cart, but that didn't work. Right now you have to actually push the cart and I don't want that. I also want the cart to rotate when the player does using the mouse using the origin of the camera as a pivot point. At first I thought using a game property, but apparently they're only relative to a single object? I've used a 2-D game engine before where you could make a property (called an Attribute) that was relative to the scene, game, or character. I'd appreciate it if it could be done using logic bricks, as I'm still working on Python. I feel like I'm not explaining this right, so just add a comment if you need clarification.


If your basically going to have the cart as the player's body, then parent the camera to the cart.

In this example, I'm using a pretty blue cube, and not a cart.

enter image description here

This is actually rather simple - you want the camera to be able to look around, and then drive the cube/player/cart in the direction the camera is facing, and have the camera follow? easy. I'm assuming your using the mouse look actuator on the camera.

enter image description here

If you are, delete or disable it for now, because there is a better way. While this works for the camera, it only works in terms of a spectator, free floating camera. This will make more sense if you think of it in terms of a battleship gun. On a battleship turret, the base rotates from left to right, and the barrel, mounted in the base, rotates up and down. Although the barrel can point in all directions, the base remains even. We want a setup similar to this. On the player/physics cube/ cart, put a mouselook actuator which only allows motion right to left.

enter image description here

Why is the Y disabled? In 2D terms, the X axis is left to right, and the Y axis is top to bottom. By disabling the Y, we are only allowing the mosuelook actuator to respond to mouse movement from left to right.

Now, if we push play, we should be able to move the mouse and rotate the camera from side to side.

Now, we can put the same logic setup on the camera, but this time, the mouse look actuator will only respond to mouse motion on the Y axis.

enter image description here

Now, we can put the WASD logic on the physic cube/player/cart/whatever, and it will move forward along the ground in the direction the camera is facing - not into the ground when looking down, or up into the sky when looking up.

enter image description here

Now, for new BGE users, I think it is sometimes helpful to play around with an already working file - see how or why things work. Staring at a blank file can only help someone so much, so feel free to play around with this blend.

  • $\begingroup$ Do I need to put them on a certain physics type, and I'm setting the carts/cubes parent as the camera not vise versa right? Cause it's not working. I must be missing something; Adding the .blend would help me a lot. BTW I like your tooltips $\endgroup$ – Unnamed Sentient Being Sep 20 '16 at 14:09
  • $\begingroup$ @SammySwanson added the blend file. $\endgroup$ – X-27 wants to Reinstate Monica Sep 20 '16 at 15:08
  • $\begingroup$ The always sensor didn't work, but using the mouse sensor and set to movement did... $\endgroup$ – Unnamed Sentient Being Sep 23 '16 at 1:14
  • $\begingroup$ Oh wait, nvm. I didn't click that little ' " ' button! $\endgroup$ – Unnamed Sentient Being Sep 23 '16 at 1:16

How about parenting the cart to the player object?

  • $\begingroup$ While this may technically answer the question, it isn't much help to someone who doesn't know what that means. Please add some more information and details on how to do this. $\endgroup$ – PGmath Sep 19 '16 at 14:36
  • $\begingroup$ this would only work if the camera could only rotate along the Z axis. with his setup, when you look down, and press forward, you would be trying to drive into the ground. $\endgroup$ – X-27 wants to Reinstate Monica Sep 20 '16 at 1:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.