Converting C# Controller from WASD Controls to Click-Based

Hi everyone, I’m trying to convert the C# Character Controller scripts to mouse click based. But I’m not sure how. How do you detect the mouse click and where it clicks? Then from there it’s just a simple transform.translate right?

You can do a raycast down onto your terrain from the screen click location. Then I suppose you can move towards this point at some speed using Vector3.MoveTowards. If you need collision avoidance, you can eventually look at using navmesh’s to move your character to the point you clicked.

the raycast code is pretty simple. What I like to do is put the terrain in its own layer and only raycast against that object

var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast(ray, hit, 100)) {
    //hit.point will contain position to move to
    //store this somewhere and move towards it
}