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 Xerather · May 30, 2020 at 03:54 PM · scripting problemprefabsplatformermobile devices

how d you change PlatformEffector2D rotationaloffset change as prefabs in android?

So i'm creating a 'platformer' android game. in my game, there is a oneway platform that enables player to stand on top of it from below. i want to make player able to go down the platform when 'Jump' button and left analog is tilted on -y coordinate. i did make it and turn it into a prefabs. As i do some test somehow the script only affect the last object i put in the scene, so if there is platform A, and copied it as platform B, Platform A won't have its rotationaloffset changed, while platform B is working. and if i copied one more time as platform C, platform B stopped working while C is working. when i try to Debug.log(GameObject.name) , the last one ( Platform C in this case ) is the only debug that printed.

here is a snippet of my 'platform' code

 public class half_bridge : MonoBehaviour
 {
     private PlatformEffector2D effector;
     private bool drop;
 
     public bool sc;
 
     private void Start()
     {
         effector = this.GetComponent<PlatformEffector2D>();
     }
 
     private void Update()
     {
         sc = FindObjectOfType<btn_jump>().GetComponent<btn_jump>().get_droptrigger();
         /*
          
         this works but impossible for phones :(
         if (Input.GetKeyDown(KeyCode.P))
         {
             Debug.Log("sc." + this.gameObject.name);
             dropping();
             FindObjectOfType<btn_jump>().GetComponent<btn_jump>().dis_droptrigger();
         }
 
         */
 
         if (sc)
         {
             Debug.Log("sc." + this.gameObject.name);
             dropping();
             FindObjectOfType<btn_jump>().GetComponent<btn_jump>().dis_droptrigger();
         }
     }
 
     public void dropping()
     {
         Debug.Log("drop");
         effector.rotationalOffset = 180f;
         StartCoroutine(backtozero());
     }
 
     IEnumerator backtozero()
     {
         yield return new WaitForSeconds(0.5f);
         effector.rotationalOffset = 0f;
     }       
 }

and this is my jumpbutton code

 public class btn_jump : MonoBehaviour ,IPointerDownHandler
 {
     private bool pointerdown;
     private bool drop;
 
     public bool droptrigger;
 
     private void Update()
     {
         drop = GameObject.FindGameObjectWithTag("player").GetComponent<CharacterController>().isdrop();
 
         if (pointerdown)
         {
             if (!drop)
             {
                 jump();
             }
             else
             {
                 dropping();
             }
             pointerdown = false;
         }
     }
 
     public void OnPointerDown(PointerEventData eventData)
     {
         pointerdown = true;        
     }
 
     void dropping()
     {
         droptrigger = true;
         //FindObjectOfType<half_bridge>().dropping();
     }
 
     void jump()
     {
         FindObjectOfType<CharacterController>().jump();
     }
 
     public void dis_droptrigger()
     {
         droptrigger = false;
     }
 
     public bool get_droptrigger()
     {
         return droptrigger;
     }
 }


Using Input.getkeydown(keycode.p) works as i want it to be, but it imposibble on phone. can you help me ?

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

235 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 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

Unity loading prefabs difficulties. optimization 1 Answer

Is there any problem in using assets as prefabs instead of just gameobject? 0 Answers

Calling a function via button from instance of prefab 1 Answer

How to make my camera follow a prefab and update it to follow the instance of same prefab the generated after the same prefab ? 0 Answers

How do I make a Mobile touch screen joystick for my PLayer in 2D platformer? 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