Hi guys.
Im programming a Platformer and want to allign the Player to the ground while on slopes. I read about there is a way by getting the angle between the ground and the normal via Raycasting. Now i tried to get a Raycast going but i failed.
I wrote this and checked on a lot of helpsites wich all told me the same.
public float distance = 100f;
Vector3 targetLocation;
void Update()
{
RaycastHit hit;
if (Physics.Raycast(transform.position, Vector3.down, out hit, distance))
{
Vector3 targetLocation = hit.point;
Debug.DrawLine(transform.position, hit.point, Color.red);
}
}
Now i should see a Raycast in the Editor but i dont am i doing anything wrong pls help. Thanks in advance.