Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by yevoc · Apr 03, 2011 at 10:22 PM · movementterrainplanestuckwasd

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?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by yevoc · Apr 04, 2011 at 06:22 PM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

No one has followed this question yet.

Related Questions

How do i change the unity controls? (not the game) 0 Answers

Movement issues with keyboard 2 Answers

NPC movement problem on slopes 1 Answer

I have a game that I want to create a tilted plane in. 1 Answer

How do I do left to right movement with ONLY the WASD keys? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges