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 /
  • Help Room /
This question was closed Jan 09, 2016 at 09:36 PM by Le-Pampelmuse for the following reason:

Too subjective and argumentative

avatar image
0
Question by BrennaMurphy · Jan 07, 2016 at 08:13 AM · inputcharacter controllery-axisfpscontrollerfpc

How to move character controller on x, z, AND y axes?

I would like my character controller to be able to move on the x, y and z axes on key commands.

For example,
move on z axis with up and down arrows
move on x axis with left and right arrows
move on y axis with r key and f key

Of course moving on the x and z axis is the default and is working fine. But how do I add the ability to move on the y axis?

I've tried modifying FPSInputController script

from

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

to

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

And in ProjectSettings/Input, I assign
Horizontal to X axis and up down arrow keys and
Vertical to X axis and right left arrow keys and
I create a new axis called UpDown and assign it to the Y axis and r and f keys.

But no change happens. All the arrow keys act normally but r and f keys do nothing.

Any suggestions on modifying my approach? Or a whole new approach?

My game is a big object floating in space (no floor) and I want the character to be able to explore around the outside of it in all directions including up and down. (no gravity)

Thank you for any tips!

Comment
Add comment · Show 3
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 ShadyProductions · Jan 07, 2016 at 08:28 AM 0
Share

try applying the vertical one in the Y axis, don't know why you want to walk in all 3 axis though.

avatar image KdRWaylander ShadyProductions · Jan 07, 2016 at 10:26 AM 0
Share

Flying into space D_D

avatar image Le-Pampelmuse · Jan 09, 2016 at 09:36 PM 2
Share

Hi. This question is off-topic, simply because it is a subjective, non-specific How-To question and it starts discussions. This doesn't mean it's a bad question though ;)

But, these kind of questions are best searched for on Google and or directly on Unity Forums. You may find hundreds of answers for "how to make a player move", because it's one of the most basic things. :)

Please stick to the forum rules when posting questions. You can find them here and here. It is also the moderator's fault for publishing this.

Another tip: When you accept an answer, it means the question is answered to your satisfaction and you should close the question now (using the small black cog wheel on the right of the question title). This helps keeping the forum organized and takes some work away from the moderators. :D

2 Replies

  • Sort: 
avatar image
1
Best Answer

Answer by Masterio · Jan 07, 2016 at 10:37 AM

Just configure a rigidbody as you want.

 using UnityEngine;
 using System.Collections;
 
 [RequireComponent (typeof (Rigidbody))]
 public class SpaceController : MonoBehaviour 
 {
     public float speed = 1f;
 
     private Rigidbody _rigidbody = null;
     private float _y = 0f;
 
     void Start()
     {
         _rigidbody = GetComponent<Rigidbody>();
     }
 
     void Update()
     {
         // move up
         if(Input.GetKey(KeyCode.R))
         {
             _y = 1f;
         }
         // move down
         else if(Input.GetKey(KeyCode.F))
         {
             _y = -1f;
         }
         else
         {
             _y = 0f;
         }
         
         // x, y, z move 
         Vector3 directionVector = new Vector3(Input.GetAxis("Horizontal"), _y, Input.GetAxis("Vertical"));
         
         // add force to the rigidbody
         _rigidbody.AddForce(directionVector * speed * Time.deltaTime);
     }
 }
Comment
Add comment · Show 3 · 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 Masterio · Jan 07, 2016 at 10:44 AM 0
Share

I forgot about Time.deltaTime for speed :) Now it is updated.

avatar image BrennaMurphy · Jan 09, 2016 at 09:24 PM 0
Share

thank you!

avatar image Le-Pampelmuse BrennaMurphy · Jan 09, 2016 at 09:28 PM 2
Share

You can thank people by upvoting their content.

avatar image
0

Answer by alfonio · Jan 07, 2016 at 10:37 AM

using UnityEngine; using System.Collections;

public class Controls : MonoBehaviour {

 public float PlayerSpeed = 5.0f;

 //void start = first frame what to do
 void Start () {
 }
 
 // Update is called once per frame
 void Update () {

     //movement
     transform.Translate (Vector3.up * Input ("jump") * PlayerSpeed * Time.deltaTime);
     transform.Translate (Vector2.right * Input.GetAxis("Horizontal") * PlayerSpeed * Time.deltaTime);//1.0.0
     transform.Translate (Vector3.forward * Input.GetAxis("Vertical") * PlayerSpeed * Time.deltaTime);//0.0.1
     }
 }


this one works an is easy :D

Comment
Add comment · Show 2 · 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 BrennaMurphy · Jan 09, 2016 at 09:24 PM 0
Share

thank you!

avatar image Le-Pampelmuse BrennaMurphy · Jan 09, 2016 at 09:28 PM 2
Share

You can thank people by upvoting their content.

Follow this Question

Answers Answers and Comments

7 People are following this question.

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

Related Questions

Character controller running stop animation transition 0 Answers

Huge drift Issue with xbox controllers. 0 Answers

Standard FPSController prefab ignores "Horizontal" and "Vertical" input on iOS 1 Answer

3rd person controller- anim parameters are not changing when i press stuff 0 Answers

Problem with the Character Controller on the Y-Axis,Character Controller drifting in the Y Axis 0 Answers


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