Question by 
               AlexV03 · Jun 10, 2020 at 11:52 AM · 
                scripting problemmovementwall jumpwalljump  
              
 
              I have a walljump script but the walljump doesn't work right can someone help me?
This is the script: { public float jumpForce = 1f;
 public Transform groundCheck;
 public float groundDistance = .4f;
 public LayerMask Ground;
 public bool Grounded;
 public Rigidbody rb;
 [SerializeField] private float wallJumpMultiplikatorHorizontal;
 [SerializeField] private float wallJumpMultiplikatorVertical;
 void Update()
 {
     Grounded = Physics.CheckSphere(groundCheck.position, groundDistance, Ground);
     if (Input.GetKeyDown(KeyCode.Space) && Grounded | hitStatus == HittingState.HittingRight | hitStatus == HittingState.HittingLeft)
     {
         Vector3 force = Vector3.zero;
         if (hitStatus == HittingState.NotHitting)
         {
             // Do a normal jump
             // force = Vector3.up * jumpForce;
         }
         else if (hitStatus == HittingState.HittingLeft)
         {
             // Wall Jump to the Right
             force += Vector3.right * wallJumpMultiplikatorHorizontal + Vector3.up * wallJumpMultiplikatorVertical;
         }
         else if (hitStatus == HittingState.HittingRight)
         {
             // Wall Jump to the Left
             force -= Vector3.right * wallJumpMultiplikatorHorizontal - Vector3.up * wallJumpMultiplikatorVertical;
         }
         if (force != Vector3.zero)
         {
             // Apply force
             rb.velocity = force;
         }
     }
 }
 void OnCollisionEnter(Collision collision)
 {
     if (collision.collider.CompareTag("Wall"))
     {
         float hitPoint = transform.localPosition.x - collision.transform.localPosition.x;
         if (hitPoint < 0)
         {
             // Hitting wall on the right
             hitStatus = HittingState.HittingRight;
         }
         else if (hitPoint > 0)
         {
             // Hitting wall on the left
             hitStatus = HittingState.HittingLeft;
         }
     }
 }
 void OnCollisionExit(Collision collision)
 {
     if (collision.collider.tag == "Wall")
     {
         // Left wall, not hitting
         hitStatus = HittingState.NotHitting;
     }
 }
 public enum HittingState { NotHitting, HitWallLeft, HitWallRight, HittingLeft, HittingRight };
 HittingState hitStatus = HittingState.NotHitting;
}
Does someone know what the problem is? Edit: when i jump off a wall i jump to the X and it doesn't matter which way you come from. This is the problem.
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
How can I let stuff reset in the script when touching a button 2 Answers
Hit a wall in my RTS movement controller. Issues with MoveToward and Coroutine logic. 0 Answers
implementing a wall jump 1 Answer
Unity Space Shooter Tutorial Player Will Not Move 1 Answer
how to make my character move up and down in android control (endless runner game) 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                