v0.7b Patch: the Controller and Movement update


v0.7b

Minor Changes:

  • Input Axes have been edited to be slightly more playable on controller.
  • The function for movement has been edited once again. Previously, the script went through an entire process of normalizing inputs as to make sure that diagonal inputs wouldn't be faster, but a few missing numbers meant that the entire system didn't work. This has been fixed (?). And YES, this is much more complicated than it has any right to be.


    //EXCERPT FROM PLAYER.CS
    deltaTime = Mathf.Clamp(Time.deltaTime, 0, 0.05f); 
    //Clamps time changes so that frame stutters don't send things flying away
    Vector3 attemptedMove = Vector3.zero;
    //Prepares an empty Vector3 for movement calculations


    Vector3 localVel = transform.InverseTransformDirection((rb.velocity));
    //Calculates the current velocity of the player RELATIVE to how the camera sees it

      
    Vector2 normalizedDir = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")).normalized;         
    //Gets movement inputs and turns them into a "input circle" instead of an "input square"


    if (((Input.GetAxis("Vertical") > 0) && (localVel.z < maxVel * normalizedDir.y)) || ((Input.GetAxis("Vertical") < 0) && (localVel.z > maxVel * normalizedDir.y)))         
    //If you are trying to move forward or backwards where you aren't going faster than the limit in that direction

    {
               
              attemptedMove += (transform.forward * normalizedDir.y); 
              //Add the vector to the movement calculation relative to the player


    if (((Input.GetAxis("Horizontal") > 0) && (localVel.x < maxVel * normalizedDir.x)) || ((Input.GetAxis("Horizontal") < 0) && (localVel.x > maxVel * normalizedDir.x)))
    //If you are trying to move right or left where you aren't going faster than the limit in that direction

    {
               
              attemptedMove += (transform.right * normalizedDir.x);   
              //Add the vector to the movement calculation relative to the player

    }
           
    if (!grounded)
           
    {
               
              attemptedMove = attemptedMove / 2;
           
    }                 
    //If not touching the ground, your total movement is halved


    rb.AddForce(attemptedMove * deltaTime * speed);
    //Take the total calculation and apply force accordingly, accounting for framerate, and multiplying by movement speed


    I HOPE YOU KNOW THE PAIN I WENT THROUGH TO MAKE MOVING DIAGONAL NOT AN ISSUE

    AND IT STILL DOESN'T WORK FOR WHEN YOU MOVE THE CAMERA AT THE SAME TIME AS MOVING

    • The wall has been raised to keep the Flies out.



    Closing Thoughts:

    • I know that you can use the signs to jump over the wall anyways. Player-proofing the test scene is not my priority.
    • I know that "wiggle bunnyhopping" results in much faster speeds than intended. I do not know how to fix this without breaking something else. Richie would probably just clamp all movement in the air, but that seems like a bad idea.

    Files

    v0.7b.zip Play in browser
    Sep 13, 2023

    Leave a comment

    Log in with itch.io to leave a comment.