x


Moving a rotated plane in x+z directions with WASD? (bizarre behavior)

How can I get a rotated plane object to move along the default terrain (move in the x-z plane) using WASD? The plane is perpendicular to the terrain.

I did the following steps below, and I am getting really screwy behavior when trying to move the plane. Once I make a simple modification to the stock FPSController (see bottom), the plane object will only move in the -z direction (via the S key) once I press and hold A or D. Even weirder, W does not move the plane in the +z direction if I hold A or D. Pressing W or S by themselves does nothing.

I did the following (and nothing else, starting from scratch) to get that far:

  • Create the default terrain
  • Create a plane gameobject
  • Rotate it perpendicular to the terrain (-90 in X for me)
  • Add the CharacterMotor script and FPSInputController (from Standard Assets/Character Controllers/Sources/Scripts) to the plane gameobject
  • Add SmoothFollow to the Main Camera and add the plane as the target

From here, I changed one line in FPSInputController.js to change the W/S keys from up/down(y) to in/out(z), as my plane is rotated to be perpendicular to the terrain:

motor.inputMoveDirection = transform.rotation * directionVector;

to

motor.inputMoveDirection = directionVector;

where

var directionVector = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));

At first, I worried that I was trying to do the impossible, but the plane does actually move in -z if you also get it moving in the x direction, so you'd think generic movement in Z would be possible for the plane. Is there another method to accomplishing this?

more ▼

asked Apr 03 '11 at 10:22 PM

yevoc gravatar image

yevoc
1 1 1 2

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Making a cube instead of a plane and adding the standard controllers without modifying the scripts seems to work. Shrinking one of the cube dimensions to near zero gets the same effect done and allows for WASD movement along the terrain.

I suppose the plane doesn't work because it only exists in 2 dimensions, and I needed it to move in the 3rd dimension.

While this cube solution has its texture show up on two sides instead of one for the plane, I can work around that by masking with multiple cubes.

more ▼

answered Apr 04 '11 at 06:22 PM

yevoc gravatar image

yevoc
1 1 1 2

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1466
x1362
x248
x65
x36

asked: Apr 03 '11 at 10:22 PM

Seen: 1182 times

Last Updated: Apr 03 '11 at 10:22 PM