Help for Restart Level
Hello everyone I need help about my new game. When I click Restart button[Application.LoadLevel (Application.loadedLevel)] my swipeshoot isn't work. What's the problem that I can't find it. Help me Please.
My code:
private const float DEADZONE = 30.0f; private const float MAXIMUM_PULL = 50.0f;
private bool isBreakingStuff;
private Rigidbody2D rigid;
public float speed = 10.0f;
float time = 0f;
public Transform ballsPreview;
public GameObject tutorialContainer;
// Use this for initialization
public void Start ()
{
tutorialContainer.SetActive (true);
ballsPreview.parent.gameObject.SetActive (false);
rigid = GetComponent<Rigidbody2D> ();
}
// Update is called once per frame
public void Update ()
{
if (!isBreakingStuff)
{
PoolInput ();
}
}
public void PoolInput()
{
Vector3 sd = MobileInput.Instance.swipeDelta;
sd.Set (-sd.x, -sd.y, sd.z);
if (sd != Vector3.zero)
{
if (sd.y < 0)
{
ballsPreview.parent.gameObject.SetActive (false);
}
else
{
ballsPreview.parent.up = sd.normalized;
ballsPreview.parent.gameObject.SetActive (true);
ballsPreview.localScale = Vector3.Lerp (new Vector3 (1, 1, 1), new Vector3 (1, 3, 1), sd.magnitude / MAXIMUM_PULL);
}
}
if(MobileInput.Instance.release)
{
isBreakingStuff = true;
tutorialContainer.SetActive (false);
ballsPreview.parent.gameObject.SetActive (false);
SendBallInDirection(sd.normalized);
}
}
public void SendBallInDirection(Vector3 dir)
{
rigid.velocity = dir * speed;
}
}
Comment