- Home /
Question by
MagicGeek123 · Apr 19, 2014 at 04:57 PM ·
moveclicktools
I get errorsfor my Click to Move Script
i keep getting errors it would help if some one told me how to fix these errors Assets/ClickToMove.cs(23,17): error CS1525: Unexpected symbol }' Assets/ClickToMove.cs(42,27): error CS1547: Keyword
void' cannot be used in this context Assets/ClickToMove.cs(42,28): error CS1525: Unexpected symbol (', expecting
)', ,',
;', [', or
=' Assets/ClickToMove.cs(55,1): error CS8025: Parsing error
using UnityEngine;
using System.Collections;
public class ClickToMove : MonoBehaviour
{
public float speed;
public CharacterController controller;
private Vector3 position;
// Use this for initialization
void Start ()
{
position = transform.position;
}
// Update is called once per frame
void Update ()
{
if(Input.GetMouseButton(0))
{
//locate clicked spot
locatePosition()
}
//move to clicked spot
moveToPosition()
}
void locatePosition ()
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(ray, out hit, 1000))
{
position = new Vector3(hit.point.x, hit.point.y, hit.point.z);
Debug.Log(position);
}
}
void moveToPosition()
{
if(Vector3.Distance(transform.position, position)>1)
{
Quaternion newRotation = Quaternion.LookRotation(position-transform.position);
newRotation.x = 0f;
newRotation.z = 0f;
transform.rotation = Quaternion.Slerp(transform.rotation,newRotation, Time.deltaTime * 10);
controller.SimpleMove(transform.foward * speed);
}
}
}
Comment