we solved this by calculating the actual slope angle, and slide direction, and figuring out the component gravity.
It should look roughly like this I think
if(groundSlopeAngle > 45){
slideVal += groundSlopeDir*Time.deltaTime*gravity*Mathf.Sin(groundSlopeAngle*Mathf.Deg2Rad)
}
else{
slideVal = slideVal*.95f;
}
motionDirection = inputMotion;
motionDirection += slideVal;
You can then add this to your normal target position the same way you add gravity.
Over a small ‘bump’ if you run over it, your running speed will overwhelm the effects of sliding. However if you try to run up a hill, you will only make it so far before the cumulative effect of sliding overpowers it.
Add some conditions to determine when you are sliding, and how it falls off.
we solved this by calculating the actual slope angle, and slide direction, and figuring out the component gravity.
It should look roughly like this I think
if(groundSlopeAngle > 45){
slideVal += groundSlopeDir*Time.deltaTime*gravity*Mathf.Sin(groundSlopeAngle*Mathf.Deg2Rad)
}
else{
slideVal = slideVal*.95f;
}
motionDirection = inputMotion;
motionDirection += slideVal;
You can then add this to your normal target position the same way you add gravity.
Over a small ‘bump’ if you run over it, your running speed will overwhelm the effects of sliding. However if you try to run up a hill, you will only make it so far before the cumulative effect of sliding overpowers it.
Add some conditions to determine when you are sliding, and how it falls off.
Here is how we got the angles needed
void OnControllerColliderHit (ControllerColliderHit hit){
Vector3 temp = Vector3.Cross(hit.normal, Vector3.down);
groundSlopeDir = Vector3.Cross(temp, hit.normal);
groundSlopeAngle = Vector3.Angle(hit.normal,Vector3.up);
}