Question by 
               Esecuzione · May 04, 2017 at 02:06 PM · 
                c#movementscript.  
              
 
              I have problems with scripting movement, anyone can help me?
It's the first time using Unity and I wanted to make my character move in a certain direction pointed by the mouse. I foud on the guide a predetermined script but it didn't work and the program said there were some errors. I changed it a bit and the program didn't signal me any error. But now the program won't attach the script anymore to the object. There's the script: what am I doing wrong?
using System.Collections; using System.Collections.Generic; using UnityEngine;
// MoveToClickPoint.cs
public class MoveToClickPoint : MonoBehaviour { UnityEngine.AI.NavMeshAgent agent;
 void Start() {
     agent = GetComponent<UnityEngine.AI.NavMeshAgent>();
 }
 void Update() {
     if (Input.GetMouseButtonDown(0)) {
         RaycastHit hit;
         if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 100)) {
             agent.destination = hit.point;
         }
     }
 }
}
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                