override protected void FixedUpdate() { base.FixedUpdate(); if (IsAlive()) { float horizontal = Input.GetAxis("Horizontal"); float vertical = Input.GetAxis("Vertical"); Vector2 mousePos = Camera.main.ScreenToWorldPoint(new Vector2(Input.mousePosition.x, Input.mousePosition.y)); Move(horizontal, vertical); LookAt(mousePos.x, mousePos.y); if (currentWeapon != null) { // TODO : handle joypad button WeaponEngine weaponEngine = currentWeapon.GetComponent <WeaponEngine>(); // TODO ajouter controls manager pour switch clavier/sourie (lastInput = clavier OU stick) Vector2 position = new Vector2(transform.position.x, transform.position.y); Vector2 direction = new Vector2(Input.GetAxis("RightStickX"), Input.GetAxis("RightStickY")); if (direction.magnitude > 0) { weaponEngine.Aim(position + direction); weaponEngine.Fire(gameObject, direction); } else { weaponEngine.Aim(mousePos); if (Input.GetMouseButton(0)) // PRESSED //Debug.Log("Pressed left."); { direction = mousePos - position; weaponEngine.Fire(gameObject, direction); } } if (Input.GetMouseButtonDown(1)) //CLICK { Debug.Log("Clicked right. ROULAAAAAADE"); } if (Input.GetMouseButtonDown(2)) { Debug.Log("Clicked middle."); } } } }
// Update is called once per frame protected override void FixedUpdate() { base.FixedUpdate(); if (IsAlive()) { GameObject player = GameObject.FindGameObjectWithTag("Player"); GameObject core = GameObject.FindGameObjectWithTag("Core"); Vector3 move = new Vector3(); // TODO : shoot & jump occasionnaly if (player != null) { move = player.transform.position - transform.position; LookAt(player.transform.position.x, player.transform.position.y); if (currentWeapon != null) { WeaponEngine weaponEngine = currentWeapon.GetComponent <WeaponEngine>(); weaponEngine.Aim(player.gameObject.transform.position); if (shotEnabled) { shotEnabled = false; weaponEngine.Fire(this.gameObject, player.transform.position - this.transform.position); } } } if (core != null) { move = core.transform.position - transform.position; } Move(move.x, move.y); } else { // Move(0, 0); // empecher slide (a faire autrement) } }