Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7683849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:53:26+00:00 2026-05-31T18:53:26+00:00

i have a character controller which jumps but while jumping i want to change

  • 0

i have a character controller which jumps but while jumping i want to change the x position of the character so basically he can turn while jumping, this is my attempt so far

     //start of character controller
    CharacterController controller = GetComponent<CharacterController>();
    if (controller.isGrounded) {

     //get the player vector movement vector
         movePlayer = new Vector3(Input.acceleration.x,0,1);
         //float h = Input.acceleration.x;
         //translate the players movement
         transform.Translate(movePlayer * moveSpeed * Time.deltaTime);
         //the run animation
         animation.CrossFade("run");

    //restrict the movement of x-axis for player
    Vector3 pos = transform.position;
    pos.x = Mathf.Clamp(pos.x, -3.0f, 3.0f);
    transform.position = pos;

   if (Input.GetButton("Jump")){
    //my ptoblem is here, the x axis on the vector3 is not happening    
    movePlayer =transform.TransformDirection(new   Vector3(Input.acceleration.x,jumpSpeed,forwardJumpSpeed)); 


              }  

         }

    // attach the gravity and move controller     
    movePlayer.y -= gravity * Time.deltaTime;
    controller.Move(movePlayer * Time.deltaTime);

current code:

void Update() {

    CharacterController controller = GetComponent<CharacterController>();

         //get the player vector movement vector
         movePlayer = new Vector3(Input.GetAxis("Horizontal"),0,1);
         //float h = Input.acceleration.x;
         //translate the players movement
         transform.Translate(movePlayer * moveSpeed * Time.deltaTime);
         //the run animation
         animation.CrossFade("run");

    //restrict the movement of x-axis for player
    Vector3 pos = transform.position;
    pos.x = Mathf.Clamp(pos.x, -3.0f, 3.0f);
    transform.position = pos;

    if (controller.isGrounded) {

   if (Input.GetButton("Jump")){

    movePlayer =transform.TransformDirection(new Vector3(Input.acceleration.x,jumpSpeed,forwardJumpSpeed)); 


              }


         }

     movePlayer.y -= gravity * Time.deltaTime;
    controller.Move(movePlayer * Time.deltaTime);

this is my current code, the jump if statement is inside the if(controller.isGrounded) the character still moves but when i press spacebar it deosnt jump anymore.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:53:27+00:00Added an answer on May 31, 2026 at 6:53 pm

    When the player jumps its no longer grounded so any code under the if(controller.isGrounded) is not called. Put your movement code outside it but keep the jumping code inside it and it’ll work fine.

    // movement code goes here
    
    // Keep the jumping code inside this if-statement
    if (controller.isGrounded) {
        if (Input.GetButton("Jump")){  
           movePlayer =transform.TransformDirection(new Vector3(Input.acceleration.x,jumpSpeed,forwardJumpSpeed)); 
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using an Account Controller which doesnt have its own table but uses
I have some 256-character strings of hexadecimal characters which represent a sequence of bit
I have previously read Spolsky's article on character-encoding, as well as this from dive
I have a string that contains a czech character. the string is 0bálka This
I have ascii strings which contain the character \x80 to represent the euro symbol:
I'm using CodeIgniter and I have a controller which processes uploads using AJAX. The
I have a User controller and User model. This model and associated database table
I have this route: {controller}/{id}/{action} Because I think it makes more sense from RESTful
I have a posts controller on a small test website I'm making. I want
This question is a little odd, and I have spent a fair while pushing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.