I got most of it down however there are a few lines that confuse me
CharacterController controller = GetComponent<CharacterController>();
float snapDistance = 1.1f; //Adjust this based on the CharacterController's height and the slopes you want to handle - my CharacterController's height is 1.8
RaycastHit hitInfo = new RaycastHit();
if (Physics.Raycast(new Ray(transform.position, Vector3.down), out hitInfo, snapDistance)) {
isGrounded = true;
transform.position = hitInfo.point;
transform.position = new Vector3(hitInfo.point.x, hitInfo.point.y + controller.height / 2, hitInfo.point.z);
} else {
isGrounded = false;
}
Here's what I got so far
var controller : CharacterController;
var snapDistance : float = 1.1;
var hitInfo : RaycastHit;//new RaycastHit() confuses me. What's the new for and why does he write RaycastHit for a second time and then follow it up with ()
function Start()
{
controller = GetComponent(CharacterController);
}
function Update()
{
if(Physics.Raycast(what does new Ray do?(transform.position, Vector3.down), what does out do?, snapDistance))
{
isGrounded = true;
transform.position = hitInfo.point;
transform.position = /*not sure if new works in UnityScript*/ Vector3(hitInfo.point.x, hitInfo.point.y + controller.height / 2, hitInfo.point.z);
}
else
{
isGrounded = false;
}
}