Hi I am making a game where I need to click on a column and it will pause for a second. This is the code I am using however it does not seem to work. I am not getting any errors, it just isnt working and it is not printing anything in the console. thanks!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SquareScript : MonoBehaviour {
public float moveSpeed;
private float moveTimeCounter;
public float moveDistance;
private Vector3 endPos;
private float averageDTime;
private int averageDTCounter;
private bool moving;
public Main refToMain;
// Use this for initialization
void Start () {
refToMain = GameObject.FindGameObjectWithTag ("GameController").GetComponent<Main> ();
}
// Update is called once per frame
void Update () {
if (transform.position.y > 8 || transform.position.y < -8) {
Destroy (gameObject);
}
if (moving) {
if (moveTimeCounter <= 1) {
moveTimeCounter += Time.deltaTime * moveSpeed;
averageDTime += Time.deltaTime;
averageDTCounter++;
} else {
moveTimeCounter = 0;
moving = false;
//print (averageDTime / averageDTCounter);
averageDTCounter = 0;
averageDTime = 0;
}
transform.position = Vector3.Lerp (transform.position, endPos, moveTimeCounter);
}
}
public void Move(string moveDirection){
moving = true;
if (moveDirection == "up") {
endPos = new Vector3 (transform.position.x, transform.position.y + moveDistance, 0);
}
if (moveDirection == "down") {
endPos = new Vector3 (transform.position.x, transform.position.y - moveDistance, 0);
}
}
public void OnMouseStay(){
if (Input.GetMouseButton (0)) {
print ("clicked");
if (tag == "SquareLeft") {
refToMain.leftColumnOn = false;
print ("left");
}
if (tag == "SquareMid") { refToMain.midColumnOn = false;
}
if (tag == "SquareRight") { refToMain.rightColumnOn = false;
}
}
}
}