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 aleem.razzaq09 · Dec 11, 2013 at 08:22 AM · 2dbounce

Bounce value not change in script for 2D object in Unity4.3.

Hi, I am working on unity4.3 and facing few strange responses. First it was ray cast as I already posted question. Now I couldn't change the value of bounce of 2D object in script. I have 2D object in which I added physic material and set bounce value to 0.9 but I want when this object collide with any foam material then it will reduce down to 0.3 so that it look like real. I am doing like this "collider2D.sharedMaterial.bounciness=0.3f" but its bouncing same as it is as it was 0.9. I also logged this after changing value and it shows 0.3, value is changed but bounces is not changed. Is this bug of Unity3d or I have to do some thing different way to change value. Kindly suggest me if anyone experienced this. Thanks in advance.

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

Answer by hamstar · Dec 11, 2013 at 08:59 AM

This is a bug in Unity3D. I experienced the same problem. A workaround was posted here, which is to disable and then re-enable the collider in order for the changes to take affect.

For example:

 collider2D.sharedMaterial.bounciness = 0.3f;
 collider2D.enabled = false;
 collider2D.enabled = true;

Comment
Add comment · Show 3 · 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 aleem.razzaq09 · Dec 11, 2013 at 10:42 AM 0
Share

@hamstar, Thats great u saved my day... Could you please tell me that is this possible that I can move object when I only touch or pick that desired object in 2D. Some one suggested my ray cast but I didn't work by doing that. Here is my code which move object when swipe on whole screen if(Input.touchCount>0 && Input.GetTouch(0).phase == TouchPhase.$$anonymous$$oved) { print("swiped............"); isSwiped=true; Vector2 touchdeltaposition = Input.GetTouch(0).deltaPosition; anglex = (float) (touchdeltaposition.x * Time.deltaTime 10.0); angley = (float) (touchdeltaposition.y Time.deltaTime *10.0); elevationAngle = new Vector3(anglex,angley,0); Vector3 elevation = Quaternion.Euler(elevationAngle)*transform.forward; rigidbody2D.AddForce(elevation); rigidbody2D.velocity= new Vector2(anglex,angley);

     }

I just want to move object when swipe occur only on that object. Is this also Unity bug or I am doing wrong. Here is my question for moving but It didn't work out. http://answers.unity3d.com/questions/589421/detect-touched-2d-object-in-unity3d-43.html. Thanks for your reply.

avatar image hamstar · Dec 11, 2013 at 06:31 PM 0
Share

Sorry I don't really know. Before I've done it with a Raycast, which robertu says doesn't work with 2D colliders. I guess this could work, but it might not be the best solution.

 if (Input.touchCount > 0) {
   if(renderer.bounds.Contains(Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position))) {
   // select me
   }
 }
avatar image UncoolName · Oct 14, 2015 at 07:34 PM 0
Share

Thank you very much!

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

18 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

Related Questions

how do i make pinball ? 1 Answer

Animation is not playing again in Unity 4.3 1 Answer

Game Crashes on iphone3gs and iPod touch but work fine on iPhone 4s 1 Answer

How to play and stop animation via code in Unity4.3 for 2D objects. 0 Answers

Strange GOs Bounce after parenting 2D game 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