GameObject to follow mouse with Isometric view

Hi all, I’m creating a game for my final year project and plan to only use mouse movement as the method of control. I need my character to follow the mouse at a smooth pace and the view perspective I plan to use is an Isometric one, like that of Diablo. I’m having some trouble getting started and would really appreciate some guidance, thanks.

It’s not too complicated.

Basically, you do the following steps:

  1. Continually Raycast from your mouse position so it hits the ground

  2. Call a move function that gets passed the hit.point of the Raycast

  3. Inside the move function, Lerp the character towards the hit.point.

        var Character : GameObject;//put your character object here
        var GroundMask : LayerMask;//select the layer of your ground here, or just choose Default.
        var MoveSpeed : float = 4;
        
        function Update()
        {
             var ray = Camera.main.camera.ScreenPointToRay (Input.mousePosition);
             var hit : RaycastHit;
        
             if (Physics.Raycast (ray, hit, Mathf.Infinity, TerrainMask))
             {
                  Move(hit.point);
             }
        
        }
        
        
        function Move(TargetPos : Vector3)
        {
             var StartPosition : Vector3 = Character.transform.position;
             var EndPosition : Vector3 = TargetPos;
        		
             t = 0.0;
                  
             while (t < 1.0) 
             {
        	  t += Time.deltaTime * MoveSpeed;
        	  transform.position = Vector3.Lerp(StartPosition, EndPosition, t);
                  yield;
             }
        }
    

It’s possible that you need to include a boolean that is true while the character actually moves, but this should get you started.

If you want your character to move directly via moving the mouse, you have to look into using the mouse axis.

Also, as suggested above, if you only want to move on mouseclicks, call the Move() function after checking for a mouseclick.