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 seanybaby2 · May 17, 2013 at 06:20 AM · jumpplatformerwall

Creating A wall Jump

Hey Guys, I'm trying to create a wall jump script that I have been stuck on for a while. I'm pretty new to using unityscript and coding in general and I'm trying to figure it out. Currently I am using the platformer controller that comes with unity script but I am trying to add this script to my object so he can wall jump. Thanks for your help.

 private var canWallJumpDir : Vector3 = Vector3.zero;
 private var moveDirection : Vector3 = Vector3.zero;
 var speed : float = 26.0;
 var jumpSpeed : float = 500.0;
 var gravity : float = 20.0;
 
 
     
     function Update () {        
         
         var fwd = transform.TransformDirection (Vector3.forward);
         var controller : CharacterController = GetComponent(CharacterController);
        
        
            if (controller.isGrounded == false){
                 // canWallJumpTime = Time.time;
                 moveDirection = Vector3(Input.GetAxis("Vertical"),0);
                 moveDirection = transform.TransformDirection(moveDirection);
                 moveDirection *= speed;
                 if(Physics.Raycast(transform.position, fwd, 1 && Input.GetButton("Jump"))) {
                     print("There is something in front of the object!");
                     moveDirection.y = jumpSpeed;
                
             }
         else{
             print ("We are grounded");
             }
         }
     // apply gravity
     moveDirection.y -= gravity * Time.deltaTime;
     
     // Move The controller
     controller.Move(moveDirection * Time.deltaTime);
   }
     
 @script RequireComponent (CharacterMotor)
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by jayhatmaker · May 17, 2013 at 06:55 AM

When you think through the wall jump logic, it shouldnt be so difficult.

  1. Jump.

  2. Detect if the character hits a wall.

  3. If jump key is hit while character is in air and touching the wall, jump again, but inverse the x-axis. (off from the wall)

So, in order to achieve a wall jump, you need 3 checks.

Are you in air? Are you touching the wall (not ground)? Is jump key hit again?

Comment
Add comment · Show 5 · 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 seanybaby2 · May 17, 2013 at 07:14 AM 0
Share

I'm able to get the first two checks down I think, but unable to get the third. I'm not sure if my script from character controller is interfering or if this script is messed up.

avatar image seanybaby2 · May 17, 2013 at 07:16 AM 0
Share

sweet actually just got it to work thanks lol.

avatar image jayhatmaker · May 17, 2013 at 08:04 AM 0
Share

Good to hear that you got it sorted out :)

avatar image Vonni · May 17, 2013 at 08:57 AM 0
Share

You need to add something important to your script! The first person controller uses: if(canControl && lastTimeJumped < 0.2) on normal jumps. It should also be used for wall jumps, it made my walljumping so much smoother. ( Check Character $$anonymous$$otor script ).

avatar image Pro-Odermonicon · May 22, 2017 at 12:00 AM 0
Share

I Can Get The First And Last Checks Only (I Don't $$anonymous$$now How To Detect A Wall.) Help.

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

18 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

Related Questions

Advice needed on my first c# 2D jump script 1 Answer

Dynamic jump? 1 Answer

my ball sometimes jumps higher or sometimes not 2 Answers

Whats the script for basic Character movement? 2 Answers

Different values of force applyed with AddForce don't change the speed of the gameobject 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