void Update() { if (gameObject == null) { Debug.Log("#5"); game_manager.restart(true); } Vector3 pos = transform.position; if (Input.GetKey("w")) { pos.y += v_speed * Time.deltaTime; tori.SetTrigger("walk_w"); s_r.sprite = ylos; last_pressed = "w"; } else if (Input.GetKey("a")) { pos.x -= h_speed * Time.deltaTime; tori.SetTrigger("walk_a"); s_r.sprite = vasen; last_pressed = "a"; } else if (Input.GetKey("s")) { pos.y -= v_speed * Time.deltaTime; tori.SetTrigger("walk_s"); s_r.sprite = alas; last_pressed = "s"; } else if (Input.GetKey("d")) { pos.x += h_speed * Time.deltaTime; tori.SetTrigger("walk_d"); s_r.sprite = oikea; last_pressed = "d"; } if (Input.GetKey("space")) { shoot_projectile(); } transform.position = pos; transform.rotation = Quaternion.Euler(0, 0, 0); }
private void OnTriggerEnter2D(Collider2D coll) { var name = coll.gameObject.name; if (name == "Player(Clone)") { Debug.Log("#1"); game_manager.sounds[1].Play(); new WaitForSecondsRealtime(2); Destroy(player); game_manager.restart(true); } if (name == "bulletPrefab(Clone)") { Debug.Log("#2"); Destroy(gameObject); Destroy(coll.gameObject); } }