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 mike29willems · Mar 16, 2019 at 03:17 AM · frictionphysicmaterial

PhysicalMaterial is not changing through my code. [solved]

  void Start()
     { 
         NoSlip = new PhysicMaterial
         {
             //name = "walll",
             staticFriction = 1f,
             dynamicFriction = 1f,
             frictionCombine = PhysicMaterialCombine.Maximum
         };
         Slip = new PhysicMaterial
         {
             staticFriction = 0f,
             dynamicFriction = 0f,
             frictionCombine = PhysicMaterialCombine.Minimum
         };}
  private void OnCollisionstay(Collision collision)
     {
         CapsuleCol.material = NoSlip;
     }
     private void OnCollisionExit(Collision collision)
     {
         CapsuleCol.material = Slip;
     }                                                                                                       public void TriggerJump()//this worked for changing the Ph.material
 {
     CapsuleCol.material = NoSlip;
     float counter = 0
         counter += 1f
     if(counter == 2)
     {
         CapsuleCol.material = Slip;
     }
 }

When Iam entering playmode I see that my charactercollider got a physical material attached to it but that material is not changing anymore with this code. The physical material only changed when I used a if statement in the same void function see code. What I also find out was if I changed the order of declaration in start that it would do the opposite, so the default NoSlip would change to Slip in playmode after that it wouldn't change. Things I have already tried: 1.deleting my own made p.material 2. putting code in fixedupdate 3. using other variable to hold the p.material (newslip = NoSlip;) 4. Deleting or adding p.materials to objects in scene. 5. Checking with Debug.log if OnCollisionStay works. I hope that I have given enough information, thanks in advance.

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 WarmedxMints · Mar 16, 2019 at 02:18 PM 0
Share

Check your colliders will send messages. Take a look at the collision matrix at the bottom of this page - https://docs.unity3d.com/$$anonymous$$anual/CollidersOverview.html

avatar image mike29willems WarmedxMints · Mar 16, 2019 at 03:25 PM 0
Share

Yes my collider is sending messages, both the stay en exit collider. But my P.material is still not changing... @Warmedx$$anonymous$$ints

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by mike29willems · Mar 17, 2019 at 11:20 PM

Collision were working, I tagged all walkable game object the same. The problem with that is even if u have a cube were u can walk on, the sides of that cube behave as a wall. So by tagging a walkable object like a cube, ur tagging the 'notwalkable' wall as well . Because I used OnCollisionexit to see if grounded, the moment I jump off the ground he detects the wall and think I'am grounded causing the rest of my code not to work well. Thanks for the help

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

100 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

Related Questions

How can I make different physic materials on one 3d object to make different frictions and bounciness? 1 Answer

What is the appropriate value of Friction Direction 2? 1 Answer

need platforms to move character with them, not take the character through them 1 Answer

Friction doesnt work? 0 Answers

where can I add friction direction 2 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