I want to set Spikepole y Position, but error in 100 GameManager.Spikepole' is a
field’ but a `type’ was expected, I want to fix it.
thanks!
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Text;
public class GameManager : MonoBehaviour {
#region Inspecter Variables
public GameObject HomeGroup;
public GameObject ResultGroup;
public GameObject TouchPanel;
public GameObject Panda;
public GameObject Spikepole;
public Text PointText;
#endregion
[HideInInspector] public int GamePoint = 0;
bool isGameAcive = false;
static Vector2 jumpForce = new Vector2(0,14);
static float spikepoleMoveValue = .05f;
static float positionY = 0;
void Start () {
PrePareView ();
EnableTouchPanel ();
}
void PrePareView()
{
HomeGroup.SetActive (true);
Spikepole.GetComponent<Transform> ().localPosition = Vector3.right * 3;
}
public void StartGame()
{
isGameAcive = true;
StartCoroutine ("SpikepoleMoving");
HomeGroup.SetActive (false);
ResultGroup.SetActive (false);
Panda.GetComponent<Animator> ().enabled = isGameAcive;
}
public void EndGame()
{
isGameAcive = false;
StopCoroutine ("SpikepoleMoving");
ResultGroup.SetActive (true);
Panda.GetComponent<Animator> ().enabled = isGameAcive;
}
void ResetGame()
{
GamePoint = 0;
PointText.text = GamePoint.ToString ();
HomeGroup.SetActive (false);
ResultGroup.SetActive (false);
Panda.GetComponent<Transform> ().localPosition = new Vector3 (-0.75f,-1.977f, 20);
Spikepole.GetComponent<Transform> ().localPosition = Vector3.right * 3;
}
void EnableTouchPanel()
{
TouchPanel.SetActive (true);
}
void DisableTouchPanel()
{
TouchPanel.SetActive (false);
}
#region Input Events
public void Jump()
{
if (!isGameAcive)
{
ResetGame ();
StartGame ();
}
if (Panda.GetComponent<Panda> ().HasPandaJumpTwice)
return;
if (Panda.GetComponent<Panda> ().IsPandaJumping)
Panda.GetComponent<Panda> ().HasPandaJumpTwice = true;
else
Panda.GetComponent<Panda> ().IsPandaJumping = true;
Panda.GetComponent<Rigidbody2D> ().velocity = jumpForce;
}
#endregion
IEnumerator SpikepoleMoving()
{
while(true)
{
if (Spikepole.GetComponent<Transform> ().localPosition.x < -5.5f)
{
positionY = Random.Range(-1.75f, 0.0f);
//Spikepole Y = new Vector3(Vector3.right * 3, positionY, 0.0f);
Spikepole.GetComponent<Transform>().localPosition = Vector3.right * 3;
//Spikepole.GetComponent<Transform>().localPosition.y = Y;
}
Spikepole.GetComponent<Transform> ().localPosition += Vector3.left * spikepoleMoveValue;
yield return new WaitForEndOfFrame ();
}
}
}
public class GM{
private static GameManager _gameManager = null;
public static GameManager GameManager{
get{
if (_gameManager == null)
_gameManager = GameObject.FindObjectOfType<GameManager> ();
return _gameManager;
}
}
}