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
0
Question by Ronanator · Jun 11, 2021 at 07:58 PM · 3dcharactercontrollerplatformer

Character controller stopping.

So I'm creating a 3d platformer and for some reason when I want to jump off a wall it applies the motion but stops half a second later I don't know what is the cause of the issue it may have something to do with my other movement but I don't want to disable it because I want the player to have full control in the air. (also my code may be a mess I'm trying to fix it)

Thanks

 public class CharacterControls : MonoBehaviour
 {
     // Animator.
     public Animator anim;
   
     // Inputs.
     public InputActionReference movementControl;
     public InputActionReference UpDownControl;
 
     // character controllers
     public CharacterController controller;
     public MovingPlatForm ExternalMove;
 
     // Other Files.
     public WallJumpBoxCheck wallchecks;
 
     // Movement..
     [SerializeField] private float speed = 10;

     //Facing.
     bool directionFacing;
     public Transform character;
 
     // controls ground identifyers
     public bool isGrounded;
     public float groundDistance = 0.4f;
     public LayerMask groundMask;
     public Transform groundCheck;
 
 
     // Controls.
     public Vector3 playerVelocity;
     public Vector3 move;
 
     // Jump + Double jump.
     public float playeraction;
     public bool isjumping;
     public bool isWalljumping = false;
     [SerializeField] private float jumpSpeed = 10;
     public float gravityValue = -9.81f;
     public float wallJumpSpeed;
     public float cooldownTime;
     public float nextFireTime;
     public float wallCooldownTime;
     public float wallNextFireTime;
 
 
 
     // Camera.
     public Transform cameraMain;
 
 
     public void OnEnable()
     {
         movementControl.action.Enable();
         UpDownControl.action.Enable();
     }
     public void OnDisable()
     {
         movementControl.action.Disable();
         UpDownControl.action.Disable();
     }
 
 
     // Start is called before the first frame update
     void Start()
     {
         controller = gameObject.GetComponent<CharacterController>();
 
     }
 
     // Update is called once per frame
     void Update()
     {
         // check if player is close to the ground and return true if player is.
         isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);
         anim.SetBool("isgrounded", isGrounded);
             
             // action to control the jump
             playeraction = UpDownControl.action.ReadValue<float>();
 
             // action to control the movement
             float movementInput = movementControl.action.ReadValue<float>();
         
             // convert movement input to vector 3
             move = new Vector3(movementInput , 0, 0);
             
             // Apply Movement.
             move.y = 0;
             controller.Move(move * Time.deltaTime * speed);
             anim.SetFloat("Speed", move.x);
         if (isGrounded)
         {
             anim.SetBool("isJumped", false);
             playerVelocity.y = -2f;
             isWalljumping = false;
             isjumping = false;
         }
        
 
 
 
         //jump
 
         // check if player is grounded and presses up
         if (isGrounded && playeraction == 1)
         {
             // start timer
             nextFireTime = Time.time + cooldownTime;
             anim.SetBool("isJumped", true);
             // move player up
             playerVelocity.y += Mathf.Sqrt(jumpSpeed * -3f * gravityValue);
 
             isjumping = true;
 
         }
 
         // Apply the movement.
         playerVelocity.y += gravityValue * Time.deltaTime ;
         controller.Move(playerVelocity * Time.deltaTime *2 );
 
         // Wall jump.
 
         // Chcek if player is not grounded and check if against the wall.
         if (!isGrounded && wallchecks.iswalled && Time.time > nextFireTime)
         {
 
             if (playeraction == 1 && !isWalljumping && Time.time > wallNextFireTime)
             {
                 // Add a next wall jump timer.
                 wallNextFireTime = Time.time + wallCooldownTime;
                 playerVelocity.y = 0;
                 // Draw ray to show that the wall has been push off of.
                 Debug.DrawRay(wallchecks.hit.point, wallchecks.hit.normal, Color.red, 1.25f);
 
                 // Apply force to character
 
                 // it fucking keeps stoping. why?
                 playerVelocity.y = wallJumpSpeed;
                 move += wallchecks.hit.normal ;
                 controller.Move(move * Time.deltaTime * wallJumpSpeed);
                 controller.Move(playerVelocity * Time.deltaTime);
                 Flip();
 
                 isWalljumping = true;
                 Debug.Log("walljump");
             }
             Debug.Log("touchwall");
             isWalljumping = false;
         }
     }
 
     public void FixedUpdate()
     {
         // get value of witch way the player is moving.
         float movementInput = movementControl.action.ReadValue<float>();
         // flipping left and right
         if (movementInput < 0 && directionFacing)
         {
             Flip();
         }
         else if (movementInput > 0 && !directionFacing)
         {
             Flip();
         }
         
     }
     void Flip()
     {
         // flip the character
         directionFacing = !directionFacing;
         character.Rotate(0, 180, 0);
     }
 
 
 }


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

0 Replies

· Add your reply
  • Sort: 

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

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

I need HELP ! Wall Jump in 3D Platformer CharacterController 0 Answers

Preventing CharacterController sliding down edges on platforms, ground detection. 2 Answers

charController.move() much slower with exact same values? 0 Answers

Sprite sheet sprites into a material 0 Answers

Why is my character controller moving in unrelated directions? 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