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 /
  • Help Room /
avatar image
1
Question by Nova-1504 · Nov 29, 2016 at 11:24 PM · 2dtransformspriteladder

How to enable vertical movement in certain areas only 2d

I'm making a 2d game. The whole map, including the ladders, is part of one sprite. I want to enable vertical movement where the ladders are only. How do I do this?

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
1
Best Answer

Answer by Ninjapro2k_ · Dec 02, 2016 at 08:16 PM

I'm guessing you want something like Donkey Kong, right?

Try this: public class ClimbLadder : MonoBehaviour {

  public Transform ladder1;
  public Transform ladder2;
  //etc...

  public bool atLadder1 = false;
  public bool atLadder2 = false;
  //etc...

  float laddercheckRadius = (somewhere around 3f);

  void Update () {
       atLadder1 = Physics2D.OverlapArea ([Parameters][2]);
       atLadder2 = Physics2D.OverlapArea (Parameters);
       //etc...

       if (Input.GetButtonDown ("your climb button") && atLadder1)
            //Whatever function you want to use to climb
  }

}

It should work something like this, sorry I wasn't able to put full focus into it. ladder1, 2 and so on will be empty gameObjects placed on the ladders. This code goes on the player, and needs some Collider2D on it. Hmu if it doesn't work, I'll try to test it for myself.

[2]: https://docs.unity3d.com/ScriptReference/Physics2D.OverlapArea.html

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 Ninjapro2k_ · Dec 02, 2016 at 08:17 PM 1
Share

It's obvious, but just for clarity it's in csharp

avatar image Nova-1504 · Dec 04, 2016 at 01:09 AM 0
Share

Where it says [Parameters] [2], what goes there?

avatar image Nova-1504 · Dec 07, 2016 at 03:59 PM 0
Share

What parameters go in the Physics.OverlapArea?

avatar image Nova-1504 · Dec 09, 2016 at 03:07 PM 0
Share

Are you even still there?

avatar image Nova-1504 · Dec 12, 2016 at 01:28 PM 0
Share

Need help here

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

125 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

Related Questions

How to move a 2D object toward the position it is pointing to? 0 Answers

2D animation transitions and unexpected position changes 2 Answers

Sprite doesn't render 0 Answers

Adding sprites to same layer as bone in 2D animation rig 1 Answer

2D Outline Shader working in Node Preview But not when rendering 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