Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 GC1983 · Feb 24, 2020 at 10:39 PM · moving platformisgrounded

Character wont jump on moving object

I have two sets of platforms: one set is moving downward and the others are moving upward. The character will not jump on the downward platforms, but will on the upward ones. Im using CharacterController.isGrounded method of collision to be able to jump. My guess is that its not registering that connection when the platform is essentially falling, but the character is clearly standing on it because it will animate the walk while moving back and forth as if it is registering the grounding. Any ideas?

Thanks!

  void Update() 
         {
             //Assign static variable
             stopControls1 = stopControls;
 
             //Move Player
             PlayerRun();
         }
     
         //Player control
         void PlayerRun()
         {
             if(!stopControls)
             {
                 //Check if is on the ground
                 if(charController.isGrounded)
                 {    
                     //If grounded, set to false
                     walkJumpOn = false;
                     runJumpOn = false;
                     crouchJumpOn = false;                
 
                     if(!isCrouched)
                     {
                         if (!freeFall) 
                         {
                             //Set key movement
                             moveDirection = new Vector3 (Input.GetAxis ("LeftAndRight"), 0);
                             charController.Move (moveDirection * Time.deltaTime);
                         }
 
                         //Rotate 
                         if (moveDirection != Vector2.zero)
                         {
                             Quaternion newRotation = Quaternion.LookRotation(moveDirection);
                             
                             thisTransform.transform.rotation = Quaternion.Slerp(thisTransform.transform.rotation, 
                                 newRotation, Time.deltaTime * 20);
                         }
                         
                         //If is moving
                         if(moveDirection.magnitude > 0.05f)
                         {
                             //walk 
                             if(!Input.GetKey(KeyCode.M))
                             {
                                 maxSpeed = 6;
 
                                 moveDirection *= walkSpeed;
                                 thisTransform.GetComponent<Animation>().CrossFade("Run");    
                             }
                             //run
                             else
                             {
                                 maxSpeed = 10;
 
                                 moveDirection *= runSpeed;
                                 thisTransform.GetComponent<Animation>().CrossFade("Sprint");
                             }
 
 
                         //idle
                         else 
                         {
                             thisTransform.GetComponent<Animation>().CrossFade("Idle");
                         }
                     }
 
                     //JUMP COMMANDS~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                     //Idle jump height
                     if(Input.GetButtonDown("Jump") && (!Input.GetKey(KeyCode.M) || Input.GetKey (KeyCode.M) 
                         && moveDirection.x == 0) && Input.GetAxis("Crouch") >= 0)
                     {
                         AudioControl.JumpSound();
 
                         CreateDust();
 
                         moveDirection.y = walkJump;
                         moveDirection.x = walkSpeed;
                         walkJumpOn = true;
                     }
                     
                     //Sprinting jump height
                     if(Input.GetButtonDown("Jump") && Input.GetKey(KeyCode.M) && moveDirection.x != 0)
                     {
                         AudioControl.JumpSound();
 
                         CreateDust();
 
                         moveDirection.y = runJump;
                         runJumpOn = true;
                     }
                     
                     //Walking jump height
                     if(Input.GetButtonDown("Jump") && moveDirection.x == 0 && Input.GetKey(KeyCode.S))
                     {
                         AudioControl.JumpSound();
 
                         CreateDust();
 
                         moveDirection.y = walkJump;
                         crouchJumpOn = true;
                     }
 }
 
 //If not on the ground...
                 if(!charController.isGrounded)
                 {
                     //Assign inputs
                     moveDirection.x = Input.GetAxis("LeftAndRight");
                     
                     //If jump key is let go, fall to the ground
                     if(Input.GetButtonUp("Jump"))
                     {
                         moveDirection.x = 0;
                         moveDirection.y = moveDirection.y - fallSpeed;    
                     }
 //Create gravity
                 moveDirection.y -= gravity * Time.deltaTime;
                 
                 //Check for jump input
                 charController.Move(moveDirection * Time.deltaTime);    
             }     
         }
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

2 Replies

· Add your reply
  • Sort: 
avatar image
-1

Answer by CarlHaeggman · Feb 25, 2020 at 09:24 AM

Are you using tags or something like that to identify if the character is standing on an object which it can jump on?

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 GC1983 · Feb 25, 2020 at 08:57 PM 0
Share

No...Im using CharacterController.isGround. It works fine on all other objects it lands on. And as mentioned, it works fine on the upward moving platforms. Its only the downward ones that dont work.

avatar image
0

Answer by ellimyt1 · Feb 25, 2020 at 09:16 PM

Is your character jump mechanic code within the Update or FixedUpdate ? The latter is for physics, so you probably want all movement stuff within Update itself. This should be checked also for your platforms movement code.

Seeing some of your code for these sections would be handy, so that we can reproduce.,@GC1983 is your jump mechanic being checked within the Update() or FixedUpdate()? It probably should be the former. The other change that might be worth doing, is moving where/when your platform movement mechanic happens.

Would be helpful to see some code with these two sections, so that we can reproduce.

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 GC1983 · Feb 25, 2020 at 11:11 PM 0
Share

I appreciate your response. I added the script. I tried used FixedUpdate() and it made no difference. I found a video on jumping mech from Press Start. Ill try that out and come back with results.

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

122 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 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 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 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 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 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 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 avatar image avatar image avatar image

Related Questions

Keeping speed while crouching in midair and remove clipping while returning to standing 2 Answers

CharacterController always starts not Grounded 2 Answers

How to prevent Character Controller from sliding during riding an animated platform? 1 Answer

How to move a Third Person Controller with a moving platform? 0 Answers

Photon Network syncing the transform of a moving platform 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