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
1
Question by Seth-McCumber · Nov 01, 2013 at 07:18 PM · charactercharactercontroller

Character Controller Movement With WASD

i Have Been Looking For Character Controllers That Use WASD For Movement Instead Of An Axis, And Can Not Find One I Need One Pretty Much Like This One

 using UnityEngine;
 using System.Collections;
 
 public class ScurgeofShadowsController : MonoBehaviour {
     public float speed = 6.0F;
     public float jumpSpeed = 8.0F;
     public float gravity = 20.0F;
     private Vector3 moveDirection = Vector3.zero;
     void Update() {
         if(CombatSystemScurge.PublicHealth <= 10) {
             speed = 1.5f;
         }
         CharacterController controller = GetComponent<CharacterController>();
         if (controller.isGrounded) {
             moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
             moveDirection = transform.TransformDirection(moveDirection);
             moveDirection *= speed;
             if (Input.GetButton("Jump")) {
                 moveDirection.y = jumpSpeed;
             }    
         }
         moveDirection.y -= gravity * Time.deltaTime;
         controller.Move(moveDirection * Time.deltaTime);
     }
 }

But Uses WASD. Thanks!

Comment
Add comment · Show 4
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
avatar image rutter · Nov 01, 2013 at 07:20 PM 0
Share

Unity can bind keys to an axis. Per the manual, default bindings include: "Horizontal and Vertical are mapped to w, a, s, d and the arrow keys."

avatar image Seth-McCumber · Nov 01, 2013 at 07:22 PM 0
Share

Well I Will Have It So It Depends On $$anonymous$$eyCodes That I Change In Game, As I Am Not A Fan Of Unitys Startup Thing Where You Setup Graphics And Input And Stuff, To $$anonymous$$e Its Ugly No Offence Unity.

avatar image rutter · Nov 01, 2013 at 07:26 PM 0
Share

In that case, you can use Input.Get$$anonymous$$ey() to check if a particular $$anonymous$$eyCode is pressed. You can calculate an appropriate moveDirection by adding Vector3.forward, Vector3.back, Vector3.left, and Vector3.right (see script reference) based on the particular keys that are currently pressed.

avatar image Seth-McCumber · Nov 01, 2013 at 07:29 PM 0
Share

Thank You! If You Post That As An Answer, I Can $$anonymous$$ark This As Answered!

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by MasterChief333 · Dec 01, 2014 at 09:04 PM

I didn't write this, but I need some rep, and I saw that if it is posted, you'll mark it a answered.

Blockquote

In that case, you can use Input.GetKey() to check if a particular KeyCode is pressed. You can calculate an appropriate moveDirection by adding Vector3.forward, Vector3.back, Vector3.left, and Vector3.right (see script reference) based on the particular keys that are currently pressed. -rutter

Blockquote

-Calieb
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

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

[C#] Movement Direction Change 2 Answers

Character controller Jumps while using Locomotion 0 Answers

Does anyone know why this is happening an how I can fix it. Character is getting stuck while walking? 0 Answers

Rigidbody character controller issues 0 Answers

Tweaking character movement 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