hello everyone,
So i’m making a Game where the Player controls a Sphere of different materials like wood, stone etc. it is on a floor which also is going to be of different materials. For the friction i’m trying to use the built-in Physic material but it doesn’t seem to work because the sphere is never slowing down not even when the Player Rigidbody.addforce is temporarily deactivated.
here is my Player movement:
using UnityEngine;
using System.Collections;
public class MovePlayer : MonoBehaviour {
public float movementSpeed;
private Rigidbody rb;
public Vector3 m_movement;
public Vector3 movementForward;
public Vector3 movementRight;
public GameObject myCamera;
private float distanceToGround;
public float notGroundedFactor;
public float m_MoveVectorMagnitud;
void Start()
{
rb = GetComponent<Rigidbody>();
distanceToGround = GetComponent<Collider>().bounds.extents.y;
}
void Update()
{
/*movementForward = transform.forward * JoyStickMine.deltaPosition.y / movementSpeed;
movementRight = transform.right * JoyStickMine.deltaPosition.x / movementSpeed;*/
if(IsGrounded())
{
movementForward = myCamera.transform.forward * JoyStickMine.deltaPosition.y / movementSpeed;
movementRight = myCamera.transform.right * JoyStickMine.deltaPosition.x / movementSpeed;
}
if(!IsGrounded())
{
movementForward = myCamera.transform.forward * JoyStickMine.deltaPosition.y / (movementSpeed * notGroundedFactor);
movementRight = myCamera.transform.right * JoyStickMine.deltaPosition.x / (movementSpeed * notGroundedFactor);
}
if(JoyStickMine.deltaPosition.y == 0)
movementForward = Vector3.zero;
if(JoyStickMine.deltaPosition.x == 0)
movementRight = Vector3.zero;
/*m_movement = movementForward + movementRight;
m_movement.y = 0;*/
m_movement = new Vector3(movementForward.x + movementRight.x, 0, movementForward.z + movementRight.z);
m_MoveVectorMagnitud = m_movement.sqrMagnitude;
if(m_MoveVectorMagnitud > 100f)
{
rb.AddForce(m_movement);
}
float horizontal = JoyStickLook.deltaPosition.x * (-5) * Time.deltaTime;
transform.Rotate(0, horizontal, 0, Space.World);
}
bool IsGrounded()
{
return Physics.Raycast (transform.position, -Vector3.up, distanceToGround + 0.1f);
}
}
Here is a picture of my wood Physics:
How can I fix the problem so the sphere uses the different Physic material correctly.
thanks in advance
-skullbeats1