Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Character Controller FPS Wall Running.

Discussion in 'Scripting' started by PLSMajesticUnity, Sep 7, 2020.

Thread Status:
Not open for further replies.
  1. PLSMajesticUnity

    PLSMajesticUnity

    Joined:
    Aug 30, 2020
    Posts:
    10
    Well hello, I started a 3D FPS Project and used a Character Controller rather than a RigidBody Player Movement and I want the Player to be able to wall Run and wall Jump I searched the media and all the Wall Running tutorials Demanded a RigidBody Movement.
    Is there a Reason for This.
    And if there is any body that can help me.
    Thanks.
     
  2. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    Hi @PLSMajesticUnity

    Nothing prevents you from using those tutorials, as the logic should be pretty much the same.

    I guess you could do a raycast or some other cast to both left and right direction, or use some other method to check contact to a wall. Then if you have enough forward velocity while in wall contact and not touching ground, don't add gravity force.

    Note that Character Controller's SimpleMove does apply gravity automatically so you might have to use Move instead.
     
    Lethn likes this.
  3. PLSMajesticUnity

    PLSMajesticUnity

    Joined:
    Aug 30, 2020
    Posts:
    10
    Thanks Helped alot
     
  4. UnrealGameDev

    UnrealGameDev

    Joined:
    Dec 5, 2020
    Posts:
    1
    I have the same problem, i even tryed to switch to the Rigid body it did not work help..
     
  5. SubicaBubica

    SubicaBubica

    Joined:
    Aug 9, 2020
    Posts:
    4
    I am using a character controller for my game, and I made wallrunning using just collisions. For example, when the player touches the wall, gravity is between -3 and -10, so he is falling slowly, make players' speed a little bigger and tilt the camera with animation. Just to mention that the character controller doesn't use OnCollisionEnter, instead, it uses OnControllerColliderHit. For tilting head in other directions, just add tag LeftWall and RightWall, so when the player touches the right wall, camera tilt into left happens and when the player touches the left wall, camera tilt into right happens.
    Hope I helped future visitors.

    Code (CSharp):
    1.     void OnControllerColliderHit(ControllerColliderHit hit)
    2.     {
    3.         if (hit.gameObject.tag == ("Wall"))
    4.         {
    5.             gravity = -10f;
    6.             speed = 17f;
    7.             //addd camera tilt here
    8.         }
    9.         else if (hit.gameObject.tag != ("Wall"))
    10.         {
    11.             gravity = -30f;
    12.             speed = 12f;
    13.             //remove camera tilt here
    14.         }
    15.     }
     
    Last edited: Feb 20, 2021
  6. SubicaBubica

    SubicaBubica

    Joined:
    Aug 9, 2020
    Posts:
    4
    If you are still looking for a solution, try to make wallrunning using collisions.
     
  7. PixelsAreBlue

    PixelsAreBlue

    Joined:
    Apr 22, 2021
    Posts:
    1
    How do i make it jump off walls?
     
  8. SirPolarBear

    SirPolarBear

    Joined:
    Jun 5, 2021
    Posts:
    1
    you may want to add a boolean for onWall that when true allows a jump and just launch away from the wall using the left and right triggers that were in the original code.
     
  9. Deleted User

    Deleted User

    Guest

    Okay, so whenever I touch the wall, the gravity changes, and Movement Speed changes but, when the character is no longer on the wall, the gravity nor the speed changes back to normal or the desired values.
     
  10. khizermaker

    khizermaker

    Joined:
    Aug 3, 2021
    Posts:
    1
    can anyone make a video i am very new and i dont understand it please help
     
Thread Status:
Not open for further replies.