void Start() { player = GameObject.FindGameObjectWithTag("Player"); playerMobility = player.GetComponent <PlayerMobility>(); mainCamera = GetComponent <Camera>(); mainCamera = Camera.main; }
private void Start() { PlayerMobility playerMobility = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMobility>(); player = playerMobility; playerPos = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>(); }
private void Start() { waypoints = new Vector3[10]; player = ali.GetComponent <PlayerMobility>(); line = GetComponent <LineRenderer>(); //line.SetPosition(0, mousePosition); //line.enabled = true; }
bool damaged; // True when the player gets damaged. void Start() { // Setting up the references. AudioSource[] allAudio = GetComponents <AudioSource> (); playerAudio = allAudio [1]; playerMobility = GetComponent <PlayerMobility> (); playerShooting = GetComponent <PlayerShooting> (); currentHealth = startingHealth; playerBody = GetComponent <Rigidbody2D> (); }
// Use this for initialization void Start() { // allEnemies = GameObject.FindGameObjectsWithTag ("Enemy"); restartButton = GetComponent <Button> (); player = GameObject.FindGameObjectWithTag("Player"); playerMobility = player.GetComponent <PlayerMobility> (); playerShooting = player.GetComponent <PlayerShooting> (); playerHealth = player.GetComponent <PlayerHealth> (); playerBody = player.GetComponent <Rigidbody2D> (); enemyManagerObj = GameObject.FindGameObjectWithTag("EnemyManager"); enemyManager = enemyManagerObj.GetComponent <EnemyManager> (); restartButton.onClick.AddListener(TaskOnClick); }
private void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Enemy")) { enemy = other.gameObject.GetComponent <Enemy>(); enemy.health--; Destroy(this.gameObject); } else if (other.CompareTag("Player")) { player = other.gameObject.GetComponent <PlayerMobility>(); player.Hp--; Destroy(this.gameObject); } }
// Use this for initialization void Awake() { player = GameObject.FindGameObjectWithTag("Player").transform; playerMobility = player.GetComponent <PlayerMobility> (); playerShooting = player.GetComponent <PlayerShooting> (); enemy = GameObject.FindGameObjectWithTag("EnemyManager").transform; enemies = enemy.GetComponent <EnemyManager> (); playButton = GetComponent <Button> (); startMenu = GameObject.FindGameObjectWithTag("StartMenu"); AudioSource[] allAudio = player.GetComponents <AudioSource> (); Welcome = allAudio [2]; playerMobility.enabled = false; playerShooting.enabled = false; enemies.enabled = false; playButton.onClick.AddListener(TaskOnClick); }
void CheckForInteraction() { if (Input.GetKeyDown(KeyCode.E)) { Vector2 playerDirection = PlayerMobility.GetPlayerDirection(); Vector2 playerPosition = new Vector2(transform.position.x, transform.position.y); RaycastHit2D hit = Physics2D.Raycast(playerPosition, playerDirection, pickupRange); Debug.DrawLine(playerPosition, playerDirection, Color.red, 2);; if (hit.collider != null) { Debug.Log("Hit wasn't null - " + hit.collider.name); if (hit.collider.tag == "Item") { Destroy(hit.collider.gameObject); } } if (hit.collider == null) { Debug.Log("We messed up"); } } }