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 jlimbach · Jun 21, 2011 at 05:05 AM · wall jump

Wall Jump and loops

Ok two questions,

Is there any while loops, or something similar, so i can do certain things while in a specific state? For example for the wall jump i want to say

// while(touching wall) { Pause for a second then drift slowly down }

otherwise gravity is normal //

But anything I try the character will drift slowly down after touching the wall then moving to the side and not actually being on the wall.

Second question. If i want him to jump off the wall, if there a better way then changing the horizontal velocity? I only want him to move about 5-10 'units' away from the way then hold normal horizontal velocity.

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by testure · Jun 21, 2011 at 05:11 AM

for your first question, you want to use a coroutine.

for your second question, you want to interpolate from one position to the other using Mathf.SmoothDamp.

Comment
Add comment · Show 3 · 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 jlimbach · Jun 22, 2011 at 03:10 PM 0
Share

mathf.smoothdamp looks goood, but I cant seem to figure out how to make it work. Does that just keep returning a value that i set to his x position?

avatar image jlimbach · Jun 22, 2011 at 03:23 PM 0
Share

I suppose my greatest question is how does Mathf.SmoothDamp work? I looked it up but cant figure it out http://unity3d.com/support/documentation/ScriptReference/Mathf.SmoothDamp.html

avatar image testure jlimbach · Jun 22, 2011 at 03:26 PM 0
Share

don't post questions or comments as answers. use the 'add new comment button'. It screws up the ordering of posts, and it doesn't read linearly. not to mention it messes up search results.

SmoothDamp eases one value to another at a specified speed. It requires a reference to a velocity variable so in order to make it happen. There's not really more to tell, that's all it does.

avatar image
1

Answer by Dreamblur · Jun 21, 2011 at 05:25 AM

  1. Either store your states in an Enum type variable or assign a toggle variable for each state.

  2. You can clamp the horizontal component of the velocity after a specified condition is fulfilled.

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 CC_1759 · Apr 01, 2021 at 09:00 PM

@jlimbach i just used an if statement...` if (CheckIfOnWallToRight() == true) { // make you jump of the wall if ((Input.GetButtonDown("Jump")) && (Input.GetButton("d"))) { playerController.GetComponent().enabled = false; rb.velocity = new Vector2(-5, 10); wallJumpedFromRight = true; } // makes you wall slide else if ((Input.GetKey("d")) && (wallJumpedFromRight == false)) { rb.velocity = new Vector2(0, -1); Debug.Log(wallJumpedFromRight); } }

     if (wallJumpedFromRight == true)
     {
         iR += 1;
     }
     if (iR >= 25)
     {
         iR = 0;
         wallJumpedFromRight = false;
         playerController.GetComponent<PlayerMovement>().enabled = true;
     }`
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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

2D Wall Jumping 1 Answer

Why isn't my player looking the other direction when I wall jump (please help I am desperate) 1 Answer

Character controller wall climb mechanic in C# 0 Answers

Why my Character's wall jump looks like teleport? 2 Answers

what is wallJumpContactNormal.y ? 2 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