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 shmulik.pangolin · Feb 25, 2015 at 08:00 PM · 2dioscolliderdifference

PolygonColliders act different on a build

Hi guys, Iv'e just encountered a very weird problem.

(BY CODE) I'm instantiating new game object, then adding a sprite renderer component and attaching a sprite object, and only after the sprite is fully loaded, I add a PolygonCollider2D, to fit the sprite iv'e just added.

That works fine on the editor, but when I run it on an iOS device, the colliders seem to be offset. here is a screenshot to demonstrate the results on both platforms - Unity Editor and iOS Device: alt text

look at the cat object. in Unity editor, I can drag it to the edge of the screen with no gap. the collider perfectly matches the sprite.
in iOS device, the picture shows you me, trying to drag the cat object as close as possible to the screen edge. for some reason, the feeling is that the collider is OFFSET, so it can't be dragged to the screen's edge.

Here's the code that adds the sprite and collider:

 currentPiece = new GameObject();
         currentPiece.transform.position = PieceDropVector();
         currentPiece.AddComponent<SpriteRenderer>();
         currentPiece.AddComponent<Rigidbody2D>();
         currentPiece.AddComponent<PieceBehavior>();
         currentPiece.GetComponent<SpriteRenderer>().sprite = physicalPieceData.spriteOBJ;
         currentPiece.GetComponent<SpriteRenderer>().sortingOrder = 3;
         currentPiece.GetComponent<Rigidbody2D>().interpolation = RigidbodyInterpolation2D.Interpolate;
         currentPiece.GetComponent<Rigidbody2D>().collisionDetectionMode = CollisionDetectionMode2D.Continuous;
         currentPiece.AddComponent<PolygonCollider2D>();
         currentPiece.GetComponent<PolygonCollider2D>().sharedMaterial = pieceMaterial;


does anyone have a clue about what went wrong? Note that I didn't change anything! right after building from unity I built the project on xCode.

Please give me an idea ho to solve this. Thanks!

untitled-3.jpg (103.6 kB)
Comment
Add comment · Show 3
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 shmulik.pangolin · Feb 26, 2015 at 10:24 AM 0
Share

please help?!:(

avatar image Helical · Feb 26, 2015 at 06:51 PM 0
Share

are you colliding with the right edge of the screen?

Also why are doing this through code exactly? you could just instantiate a premade prefab no?

avatar image haim96 · Mar 29, 2015 at 01:30 PM 0
Share

now that you found the answer... (on FB) why don't you post it and close the question? :)

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by FranzP3 · Jan 22, 2018 at 10:37 PM

Same here... Polygon collider added via script works great in the editor, then sucks in the built game (Android).

I actually don't know why this happens!

@shmulik.pangolin did you find a way to solve this?

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 NoobGaming · Jan 22, 2018 at 10:59 PM

Not by any means any kind of pro but off the top of my head it maybe a font thing? The font on the device maybe creating a edge padding around the text to guarantee it to fit within the designated space and the collider is calculating that padding and creating white space? Maybe? I don't know just spit ball here. :) Do you have "Best Fit" checked on the text in the inspector? Hopefully it helps you find an answer!

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Mesh collider cost 1 Answer

How to be dynamically attached to the PolygonCollider2D in on iOS 1 Answer

Triggers Interacting with Triggers 0 Answers

iOS ONLY stutter every 3 seconds simple 2d game,iOS ONLY constant stutter / lag every 3 seconds in simple 2D game 0 Answers

Finding the centre of two touches 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