- Home /
Moving on x / z axis prevents me from falling
I am applying velocity on X and Z axis, if i hold down a key thats near a wall, it will stick to it. I have it on Fixed Update, and only applying velocity. I really need help to fix this.
private void FixedUpdate()
{
if (!climbing)
{
z = Input.GetAxis("Vertical");
}
else
{
z = 0;
}
x = Input.GetAxis("Horizontal");
Vector3 forwardVel = transform.forward * speed * z;
Vector3 horizontalVel = transform.right * speed * x;
horizontalVel.y = rb.velocity.y;
if (Camera != null)
{
transform.rotation = Quaternion.Euler(0, Camera.GetComponent<Player_Camera>().currentY, 0);
}
rb.velocity = forwardVel + horizontalVel;
}
I do not want to use any Friction material, because i will slide off of the top of any object, even slopes. Any way to stop this friction?
Answer by Lost_Syndicate · Oct 25, 2018 at 07:19 PM
I figured out how to do it. For those of you who are wondering, i will explain. Make a new physics material, leave it on 0.6 and 0.6. Make the Friction Combine Multiply. Apply this to your player/s. On all walls you want the player not to be able to stick to, make a new physics material, set everything to 0, and leave Friction Combine on Average. Now you will notice, even if you are on the surface of the object, you will not slide off, Only steep slopes will make you fall off.
Answer by Bleakmountain50 · Oct 24, 2018 at 11:43 PM
if the problem is the player falling off the wall you can just set the rigidbody to kenetic
Your answer
Follow this Question
Related Questions
Friction in unity? 2 Answers
Distribute terrain in zones 3 Answers
Delaying Physics Calculations (Friction) 1 Answer
Re-Creating Unity's Friction and Bounce 0 Answers
How can I change friction of a Physic material in script? 1 Answer