Question by
Blooper64 · Jan 09, 2019 at 07:32 PM ·
physicsraycasthitspherecast
Having Troubles with Sphere Casts
So what I am looking for is a character controller that can detect if there grounded and the grounds normal so that I can set the player to slide
if (Physics.Raycast(transform.position + (Vector3.up * 0.1f),
Vector3.down,out hitInfo,m_GroundCheckDistance*1.5f,
Ground, QueryTriggerInteraction.Ignore))
{
GroundNormal= hitInfo.normal;
if (GroundNormal.y <= 0.8f && GroundNormal.y >= 0.3f)
{
//slideing
}
else
{
//!slideing
}
}
This code works but only when the ground is directly below them witch inst what I want so the next thing I tried was Sphere Cast witch dose not seem to work.
if( Physics.SphereCast(transform.position + (Vector3.down * 0.05f), 0.4f,Vector3.down ,out hitInfo,m_GroundCheckDistance ,Ground, QueryTriggerInteraction.Ignore)){
I also tried using a Check Sphere to check if the player is grounded and the normal ray cast to check the normal but that dose not work on inclines were the wall is so high that the ray cast dose not touche it but the Check Sphere dose
Comment