Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 AlexV03 · Jun 01, 2020 at 02:00 PM · 3dcharacter movementwalljump

How do you make an wall jump? for 3d games

I am trying to make my character wall jump so if it jumps to an wall it can wall jump but he needs to hit the ground again before wall jump again. Does someone know how to make this or already has an script? Hope someone will help

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
0

Answer by thaswasupbreh · Jun 01, 2020 at 02:09 PM

maybe you can use empty objects similar to how the ground check works and put them on the side of the player. then whenever they jump it checks first the ground then the wall and if the wall is the only one that works change a bool to false so it can't work again until the bool is changed back when the player jumps off the ground.

Comment
Add comment · 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
0

Answer by Artik2442 · Jun 01, 2020 at 02:10 PM

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class WallRun : MonoBehaviour
 {
     public GameObject player;
     public Camera cam;
 
     public Animator anim;
 
     public Rigidbody rb;
 
     RaycastHit Left;
     RaycastHit Right;
 
     Vector3 moveAlong;
 
     public bool NoTurnCam;
 
     public string Havejump;
 
     public float limit;
     public float maxDistance;
     public float offsetDist;
     float direction;
     public float force = 500;
 
     public float distanceL;
     public float distanceR;
 
     // Start is called before the first frame update
     void Start()
     {
         
     }
 
     // Update is called once per frame
     void Update()
     {
         CharacterMovement Script = player.GetComponent<CharacterMovement>();
 
         if (Input.GetKey(KeyCode.LeftShift) && !Script.touchGround)
         {
             distanceL = Vector3.Distance(Left.point, transform.position);
             distanceR = Vector3.Distance(Right.point, transform.position);
             if (Physics.Raycast(player.transform.position, player.transform.right * -1, out Left))
             {
                 if (Left.transform.GetComponent<Collider>() != null)
                 {
                     if (Vector3.Dot(Left.normal, Vector3.up) == 0 && distanceL < distanceR && distanceL < maxDistance && Havejump != "From Left" && Left.transform.gameObject.layer == LayerMask.NameToLayer("Ground"))
                     {
                         Script.canJump = false;
                         RunWallL();
                     }
                 }
                 else
                 {
                     NoTurnCam = false;
                     Script.canJump = true;
                     Havejump = "";
                     if (direction == -1)
                     {
                         anim.SetBool("RunningL",false);
                     }
                     else if (direction == 1)
                     {
                         anim.SetBool("RunningR",false);
                     }
                     direction = 0;
                 }
             }
             if (Physics.Raycast(player.transform.position, player.transform.right, out Right))
             {
                 if (Right.transform.GetComponent<Collider>() != null)
                 {
                     if (Vector3.Dot(Right.normal, Vector3.up) == 0 && distanceR < distanceL && distanceR < maxDistance && Havejump != "From Right" && Right.transform.gameObject.layer == LayerMask.NameToLayer("Ground"))
                     {
                         Script.canJump = false;
                         RunWallR();
                     }
                 }
                 else
                 {
                     NoTurnCam = false;
                     Script.canJump = true;
                     Havejump = "";
                     if (direction == -1)
                     {
                         anim.SetBool("RunningL",false);
                     }
                     else if (direction == 1)
                     {
                         anim.SetBool("RunningR",false);
                     }
                     direction = 0;
                 }
             }
             if(Input.GetKeyDown(KeyCode.Space) && direction != 0)
             {
                 rb.AddForce(Vector3.up * force);
                 Script.canJump = true;
                 if(direction == -1)
                 {
                     rb.AddForce(transform.right * force);
                     Havejump = "From Left";
                     anim.SetBool("RunningL",false);
                     direction = 0;
                 }
                 else if(direction == 1)
                 {
                     rb.AddForce(transform.right * -force);
                     Havejump = "From Right";
                     anim.SetBool("RunningR",false);
                     direction = 0;
                 }
             }
         }
         else
         {
             NoTurnCam = false;
             Script.canJump = true;
             Havejump = "";
             if (direction == -1)
             {
                 anim.SetBool("RunningL",false);
             }
             else if (direction == 1)
             {
                 anim.SetBool("RunningR",false);
             }
             direction = 0;
         }
     }
 
     void RunWallL()
     {
         Debug.Log("Wall running Left!");
         moveAlong = Vector3.Cross(Left.normal, Vector3.up);
         direction = -1;
 
         rb.velocity = new Vector3 (
             rb.velocity.x,
             Mathf.Clamp(rb.velocity.y, -limit, limit),
             rb.velocity.z
             );
 
         transform.position = Left.point + transform.right * offsetDist;
 
         NoTurnCam = true;
 
         anim.SetBool("RunningL",true);
     }
 
     void RunWallR()
     {
         Debug.Log("Wall running Right!");
         moveAlong = Vector3.Cross(Right.normal, Vector3.up);
         direction = 1;
 
         rb.velocity = new Vector3 (
             rb.velocity.x,
             Mathf.Clamp(rb.velocity.y, -limit, limit),
             rb.velocity.z
             );
         
         transform.position = Right.point + transform.right * -offsetDist;
 
         NoTurnCam = true;
 
         anim.SetBool("RunningR",true);
     }
 }
 

So, this is a script I've created to make the WallRun. It is imperfect and incomprehensible so use this Website and follow the instructions: WallRun.com It really helps me.

Comment
Add comment · 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

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

168 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

Related Questions

I cant move my character,My character wont move 0 Answers

I'm trying to make a 3D player do a wall jump. Does anyone have advice? 0 Answers

Can someone explain how this piece of code from third person prefab works ? 0 Answers

Physics platform character controller sliding issue NO parenting 0 Answers

Smooth walljumping 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