- Home /
How can I change friction of a Physic material in script?
Hi, I am doing an endless runner, firstly the friction of my physic material for the ground is 0, but when the player hit an obstacle i want to change the friction to 1, so the player stop moving. How can i do that? In c#
Each collider has a material property. You can modify the properties of that material at runtime without needing to change your material entirely.
https://docs.unity3d.com/ScriptReference/Physic$$anonymous$$aterial.html
Answer by tormentoarmagedoom · Mar 12, 2018 at 05:25 PM
Good day.
If you want the player to stop, maybe you should just change its velocity and mantain the friction.
But if you need to change the friction, you should take al look at Physic Materials.
There are 2 frictions, dynamic and static. dynamic friction is applied when object have no movement, for calculate the force needed to start moving an object. Once is moving, the dynamic friction is applied.
For my experience, i recommend you to modify speed instead of friction.
If helped, please accept the answer! :D
Your answer
Follow this Question
Related Questions
After exporting my project from my PC to my laptop the physics of my game work differently. 1 Answer
Delaying Physics Calculations (Friction) 1 Answer
How to make object bounce from one bound to another? 0 Answers
how to make trampoline in unity 3D 1 Answer
Re-Creating Unity's Friction and Bounce 0 Answers