• 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 moneymaker · Mar 04, 2014 at 02:37 PM · gameobjectcolliderspriteunity 2dphysics material

Chewing gum Physics Material 2D

I am trying to create a GameObject that should work like a chewing gum. For that I did the following:

  1. Create an empty GameObject

  2. Drag the sprite (same width and height) into the previous GameObject

  3. Add a Box Collider 2D to the GameObject

  4. Create a Physics Material 2D

  5. Add the previous Physics Material 2D to the Box Collider 2D

I used a Bounciness value of 0.3f so it bounces a little and a Friction value of 0.8f so the objects that touch it get stuck but it is not working. I also tried with several combinations of those values but with no luck.

Is this the right approach? I am new to Unity so maybe I am not getting how really Physics Material work.

Please note that I am using 2D mode settings.

Comment
Add comment · Show 2
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 Dblfstr · Mar 04, 2014 at 03:53 PM 0
Share

All of these things you can do without using an empty gameObject. you can apply all these setting to the sprite. (unless you mean texture and not sprite).

What is actually not working? Is it not bouncing? Is it not sticking?

avatar image moneymaker · Mar 04, 2014 at 10:17 PM 0
Share

The bounciness value works as I expect but the Friction value does not. When I put 0 the ball in contact slides faster but I want the opposite. So I tried with 0.8, 1, 10, 100 but the ball in contact does not get stucked. I think I will try to create a joint dynamically to get the ball stuck. What you think about that? :7

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by moneymaker · Mar 08, 2014 at 03:30 PM

I ended up using another approach that works better. Using OnCollisionEnter2D I create a SpringJoint2D connecting the object that touched it. I also change the linear drag of the same object so it does not move too much.

  public class Gum : MonoBehaviour {
     
         void OnCollisionEnter2D(Collision2D collider)
         {
             GameObject go = collider.gameObject;
             SpringJoint2D joint = gameObject.AddComponent<SpringJoint2D>();
             joint.connectedBody = go.rigidbody2D;
             go.rigidbody2D.drag = 10;
         }
     
     }

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

22 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

Related Questions

If i flip the scale from a sprite, how do i make my game object child flip aswell? 0 Answers

How click and drag a 2D game object without click and dragging the Camera Orthographic? 1 Answer

How can I check if an instantiated object collides with another instantiated object? 1 Answer

Bounds is 0 when Instantiated 2 Answers

Locate a game object using rays 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges