Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 IvanOmega60 · Oct 25, 2015 at 12:24 AM · charactercontrollerthird person controller

How to make a normal WASD controller

I've created a character controller script for a third person character, but it isn't working (I'll upload it in a .txt file) it has two errors: (Assets/CharacterMovement.cs(24,14): error CS0501: CharacterMovement.Start()' must have a body because it is not marked abstract, extern, or partial) (Assets/CharacterMovement.cs(26,14): error CS0501: CharacterMovement.SetupAnimator()' must have a body because it is not marked abstract, extern, or partial)

I need it to be something like W for forward, A+W for left-forward, etc and mouse to move the camera (in a third person character) The next I'm going to ask maybe is impossible or too difficult: Is it a way to connect for example a ps3 controller to an unity 5 game? And if it's possible, how can I change the controlls to adapt it to the ps3, xbox or psp controller? Thank you very much.link text

charactermovementthirdperson40.txt (2.7 kB)
Comment
Add comment · Show 1
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 IvanOmega60 · Oct 25, 2015 at 05:02 PM 0
Share

So, if I understood it well, first I must delete the "void Start()" and "void SetupAnimator()", then I must change the way I have it to something Joshua said, should I then write public void Start or public void SetupAnimator?(Because the body I'll be using is not abstract I think). Then I have to put what it's written here: http://docs.unity3d.com/ScriptReference/Input.html http://docs.unity3d.com/ScriptReference/Input.GetAxis.html But where do I put them in the script? I feel that I understood it wrong or just didn't understand it.

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by MrMeows · Oct 25, 2015 at 04:20 AM

Delete "void Start();" and "void SetupAnimator();". Never use semicolons when declaring functions. Also, there is no reason to declare a function that does nothing.

Comment
Add comment · Show 1 · 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
avatar image TheLazyTurtle9 · Oct 25, 2015 at 06:07 AM 0
Share

I believe he's using a technique who's name escapes me right now, but it's not a bad technique and, to my understanding gives the compiler a heads up before running ;)

avatar image
0

Answer by TheLazyTurtle9 · Oct 25, 2015 at 04:52 PM

@ IvanOmega60

As for the "WASD" controller, this is every easy! Unity actually ships "WASD" controls and you can access them by typing the following: Input.GetAxis("Horizontal");

for the "A" and "D" keys, and

Input.GetAxis("Vertical");

for the "W" and "S" keys.

As for the mouse, that gets a bit more complicated, and I'm gonna let someone else do that (look at my name for explanation)

As for the game controllers, yes! Unity does support game controllers. Go into Edit-> Project settings -> Input

after that, a quick google search for "Setting up a Xbox controller in unity" should get you on your way. Again, look at my name for explanation as to why I'm not going into further detail ;)

NOTE: the Xbox 360 and Xbox 1 controller mappings are the EXACT same!

Comment
Add comment · Show 1 · 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
avatar image IvanOmega60 · Oct 25, 2015 at 08:53 PM 0
Share

Where is Input.GetAxis? I feel totally lost right now. I've searched for WASD controller scripts all over the internet but none works the way I need. How can I do a WASD script?

avatar image
0

Answer by JoshuaMcKenzie · Oct 25, 2015 at 08:10 AM

if you don't define a body for the Start method in a script that inherits form MonoBehavior then you don't to list its name, so you can delete that. As the compiler is telling you theres no body for the SetupAnimator and is expecting the terms "abstract, extern, or partial". If CharacterMovement is planned to be a parent class then you should mark that method an abstract method. And give it an accessibility level... i.e public or protected... a private abstract method is another error.

for example:

 public abstract void SetupAnimator();

unless you're not planning on using it, then you should just delete or comment it out.

now to make your controller cross-platform supported. I would highly recommend you use the Input class and the Input.GetAxes and Input.GetButton that Unity has setup for you. It can save you a lot of headaches for most control schemes as unity has done all the architecture for you. I can recall when I first started with Unity I coded up my entire Input interface for cross platform support while not knowing about this feature.

the Input Class enables you to think of your controls as platform-independent actions and even give you the foundation to make it possible to remap controls to whatever you like while playing the game.

To see the Axes that are defined you can go to edit->Project Settings->Input, and the information will populate the inspector panel

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

6 People are following this question.

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

Related Questions

how to get the default third person character controller in unity 5 to move in midair 0 Answers

Character Controller Move in X and Z axis via camera 1 Answer

How would I get my character to be able to move while in the air after a jump? 1 Answer

I have a problem with my c# code to make my charaktercontroller jump. 1 Answer

I need help with sliding in infinite Runner please someone help 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