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 john 2 · Aug 25, 2010 at 09:59 PM · javascripty-axisclimb

how to climb a vine in 2D gameplay?

i have part of the script done but i don't know how to make the up arrow from jumping go to just upward movement.

Script:

function OnTriggerStay(hit : Collider) {

  if(hit.tag == "Vinetrig" && Input.GetKeyDown(KeyCode.UpArrow))
  {

  PlatformerController.canControl = false; //Turns off normal controls

 //What should i put here to make the player "walk" upwards on the y axis?
 }

}

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

Answer by Peter G · Aug 25, 2010 at 10:46 PM

Depending on how complicated you want your movement to be, you could do something simple like:

function OnTriggerStay(hit : Collider) {

  if(hit.tag == "Vinetrig" && Input.GetKeyDown(KeyCode.UpArrow))
  {

       PlatformerController.canControl = false; //Turns off normal controls
       cachedCharacterController.Move(Vector3.up * climbSpeed * Time.deltaTime); //Link to the character controller
       //If you use Input.GetAxis, you can have the player move up or down without writing twice as much code.

 }

}

Maybe, for some reason you can't but if you setup a vertical input in the input manager, then you will be able to save writing an identical function for the down.

//Moves player up and down. function OnTriggerStay(hit : Collider) {

  if(hit.tag == "Vinetrig" && Input.GetAxis("VerticalAxis")) //Is the user 
  //pressing up or down.
  {

       PlatformerController.canControl = false; //Turns off normal controls
       cachedCharacterController.Move(Vector3.up * Input.GetAxisRaw("VerticalAxis") * climbSpeed * Time.deltaTime); //Link to the character controller
       //Move based on the value of the input.
 }

}

Comment
Add comment · Show 2 · 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 Sean_The_Ripper · Aug 26, 2010 at 03:28 AM 0
Share

what should the "cachedCharacterController" variable be? (EX: var cachedCaracterController = )

avatar image Peter G · Aug 26, 2010 at 09:30 PM 0
Share

There are 2 ways of doing it. The slightly longer way the in much better for performance or the quick to write slow version. 1st method: var cachedCharacterController : CharacterController; function Start () { cachedCharacterController = GetComponent(CharacterController); } The slow method. Take out the cachedCharacterController var and simply say GetComponent(CharacterController).$$anonymous$$ove(); in OnTriggerStay()

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

No one has followed this question yet.

Related Questions

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Setting Scroll View Width GUILayout 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Sequence of function Calls 2 Answers

Inverse function of OnTriggerStay? 3 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