I am using this script:
var smooth:int;
private var targetPosition:Vector3;
function Update () {
if(Input.GetKeyDown(KeyCode.Mouse0))
{
var playerPlane = new Plane(Vector3.up, transform.position);
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hitdist = 0.0;
if (playerPlane.Raycast (ray, hitdist)) {
var targetPoint = ray.GetPoint(hitdist);
targetPosition = ray.GetPoint(hitdist);
var targetRotation = Quaternion.LookRotation(targetPoint - transform.position);
transform.rotation = targetRotation;
}
}
transform.position = Vector3.MoveTowards (transform.position, targetPosition, Time.deltaTime * smooth);
//var controller : CharacterController = GetComponent(CharacterController);
//controller.Move(Vector3(0, 0, smooth * Time.deltaTime));
}
But I can’t figure out how to do move with CharacterController, so collisions are detected.
How about reading the [docs][1] first? [1]: http://docs.unity3d.com/Documentation/ScriptReference/CharacterController.html
– Lockstep