Hello,
I’m working on some enemy AI, and I’m using a raycast system to determine the Y position of the enemy in comparison to the floor.
What I mean is, basically, the enemy AI fires raycasts downwards, and any thing it hits (floor), the enemy position Y will aline itself with that floor position.
The problem I’m having is that when the enemy walks up a ramp, the raycasts appear to be ‘blocky’. I have included some screen shots to help you guys understand.
This is the raycast system I use:
var hit : RaycastHit;
if (Physics.Raycast (raycastPosition.transform.position, -Vector3.up, hit)) {
distanceToGround = hit.transform.position;
print("Distance: "+distanceToGround);
print("Hitting "+hit.transform);
Debug.DrawLine (raycastPosition.transform.position, hit.point, Color.red, 1);
}
As I understand, the hit.transform.position only gives the information about the position of the model as a whole. How would I retrieve precise data? I was thinking something like: hit.contacts[0].point, but I get an error.
Any ideas?
Thanks