Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 gizelgeng · Aug 15, 2020 at 06:00 AM · jumprotatingstickingperpendicular

how to jump Perpendicular to the rotating platform

Hello , first of all i wanted to apologize for my bad English. i have a simple jumping game . in this game there are rotating platforms , and a game object , whenever the player clicks mouse the game object should jump and stick to the next platform and rotate with it ,until the player clicks again. i want the game object to jump Perpendicular to the rotating platform` (again sorry for my bad English) but now in my code it dose not. and if i use Vector3.up the game object will fall down ,i've tried every thing but it dose not work

alt text

i want the game object to jump in the direction of green arrow and stick to the next platform

alt text

, here is my code

     Rigidbody2D Rig;
     public float Force =500;
     public bool gamejump = true;
     public Transform platformParent;   
     bool playerforce = false;
     bool setpos = false;
     Vector2 pos = new Vector2(0, 0);
     public Collider2D Ccollider;
     public bool bottom =false;
     public bool SPressed = false;
     void Start()
     {
         Rig = GetComponent<Rigidbody2D>();
         Ccollider = GetComponent<CircleCollider2D>();
     }
     void Update()
     {
         if (SPressed == true && Input.GetKeyDown(KeyCode.Space))
         {
             print("true");
             gamejump = true;
             Rig.AddForce(transform.up * Force);
         }    
 
         if (gamejump == true)
         {
             transform.SetParent(null);
             Rig.isKinematic = false;
             setpos = false;
         }
         else
         {
             transform.SetParent(platformParent);
             Rig.AddForce(new Vector2(0, 0));
             Rig.isKinematic = true;
             if (setpos == false)
             {
                 setpos = true;
                 transform.position = pos;
             }
 
             /*    if(Input.GetMouseButtonDown(0))
               {
                   SPressed = true;
               }
                 if(Input.GetMouseButtonUp(0))
               {
                   SPressed = false;
               }
            }*/
         }
     }
     void OnTriggerStay2D(Collider2D other)
     {
         if (other.tag == "Rotate")
         {
             SPressed = true;
             // if(SPressed==true)
             //if (Input.GetKey(KeyCode.Space) )  
             // if (Input.GetMouseButtonDown(0))
             //  {
             // gamejump = true;
             /* if (bottom == true)
              {
                  Rig.AddForce(other.transform.up * Force);               
              }
              else
              {
                  Rig.AddForce(other.transform.up * -Force);
 
              }
              }
         */
             //  }  
         }
     }
 
     void OnCollisionEnter2D(Collision2D collision)
     {
         if (collision.gameObject.tag == "Rotate")
         {
             ContactPoint2D contact = collision.contacts[0];
             pos = contact.point;
             if (collision.contacts.Length>0)
             {
                 bottom = true;
             }
             else
             {
                 bottom = false;
             }
             gamejump = false;  
         }
     }
     public void OnCollisionExit2D(Collision2D collision)
     {
         collision.collider.enabled = false;
     }
 }
 

i have to press key space 3 times to jump and i don't know why! so that is my main problem for now.

whatsapp-image-2020-08-15-at-102027-1.jpeg (15.2 kB)
whatsapp-image-2020-08-15-at-102027.jpeg (22.4 kB)
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

0 Replies

· Add your reply
  • Sort: 

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

132 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

Related Questions

Object rotates from Y velocity on Collision 2 Answers

How to make smooth jump? 1 Answer

Preventing Rotated Jumping (C#) 1 Answer

Random Server/Client Desync 0 Answers

Jump is registered when falling of platform? 1 Answer


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