Hello to everyone i´m here to ask you how can i disable the colliders in unity i´m making a flappy bir game improved because i´m learning and is the first game that i´m making what i want to do is if the shield is activated disable the colliders for some time but i can´t disable it
Player Script:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using UnityEngine.Advertisements;
public class Jump : MonoBehaviour
{
// The force which is added when the player jumps
// This can be changed in the Inspector window
public Vector2 jumpForce = new Vector2(0, 300);
private Rigidbody2D rigid;
public GameObject spawn;
public Image TapIzq;
public Image TapDer;
public Image ManoClick;
public CanvasRenderer table;
public Image GetReady;
public GameObject avion;
public Image GameOver;
private PointsScore Puntuacion;
public Transform HighScoreText;
private Invencible invencible;
void Start() {
rigid = GetComponent<Rigidbody2D>();
Advertisement.Initialize ("62729");
if (Random.value >= 0.9 && Advertisement.IsReady ()) {
Advertisement.Show();
}
}
// Update is called once per frame
void Update()
{
// Jump
if (Input.GetKeyUp("space") || Input.GetMouseButtonDown(0))
{
rigid.velocity = Vector2.zero;
rigid.AddForce(jumpForce);
}
if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0) && Application.isPlaying)
{
TapDer.enabled = false;
TapIzq.enabled = false;
ManoClick.enabled = false;
GetReady.enabled = false;
table.gameObject.SetActive(false);
Time.timeScale = 1f;
}
// Die by being off screen
Vector2 screenPosition = Camera.main.WorldToScreenPoint(transform.position);
if (screenPosition.y > Screen.height || screenPosition.y < 0)
{
Die();
}
}
// Die by collision
public void OnCollisionEnter2D(Collision2D other)
{
Die ();
}
public void Die()
{
if (PlayerPrefs.HasKey ("highscore")) {
if (PlayerPrefs.GetInt ("highscore") < GetComponent<PointsScore> ().score) {
PlayerPrefs.SetInt ("highscore", GetComponent<PointsScore> ().score);
PlayerPrefs.Save();
}
} else {
PlayerPrefs.SetInt("highscore", GetComponent<PointsScore>().score);
}
Application.LoadLevel(0);
}
}
Columns Script:
using UnityEngine;
using System.Collections;
public class Obstacle : MonoBehaviour
{
public Vector2 velocity = new Vector2(-8, 0);
public float range = 10;
// Use this for initialization
void Start()
{
GetComponent<Rigidbody2D>().velocity = velocity;
transform.position = new Vector3(transform.position.x, transform.position.y - range * Random.value + 1, transform.position.z);
}
}
Thanks for try to help me
PD Sorry for my bad english i´m a spanish person:)