No overload for method 'fireBullet' takes 0 arguments
In a game I'm making you can shoot lasers. I want them to go towards where the mouse is but I keep getting the error in the title. Here is my script:
void Update () { if (Input.GetKeyDown("space")) { GetComponent().Play(); fireBullet();
         //GameObject bullet01 = (GameObject)Instantiate(PlayerBulletGO);
         //bullet01.transform.position = BulletPosition01.transform.position;
     }
     float x = Input.GetAxisRaw("Horizontal");
     float y = Input.GetAxisRaw("Vertical");
     Vector2 direction = new Vector2(x, y).normalized;
     Move (direction, x);
 }
 void Move (Vector2 direction, float move)
 {
     Vector2 min = Camera.main.ViewportToWorldPoint (new Vector2(0, 0));
     Vector2 max = Camera.main.ViewportToWorldPoint (new Vector2(1, 1));
     max.x = max.x - 0.285f;
     min.x = min.x + 0.285f;
     max.y = max.y - 0.600f;
     min.y = min.y + 0.200f;
     Vector2 pos = transform.position;
     pos += direction * speed * Time.deltaTime;
     pos.x = Mathf.Clamp (pos.x, min.x, max.x);
     pos.y = Mathf.Clamp(pos.y, min.y, max.y);
     transform.position = pos;
     if (move > 0 && !m_FacingRight)
     {
         // ... flip the player.
         Flip();
     }
     // Otherwise if the input is moving the player left and the player is facing right...
     else if (move < 0 && m_FacingRight)
     {
         // ... flip the player.
         Flip();
     }
 }
 private void Flip()
 {
     // Switch the way the player is labelled as facing.
     m_FacingRight = !m_FacingRight;
     // Multiply the player's x local scale by -1.
     Vector3 theScale = transform.localScale;
     theScale.x *= -1;
     transform.localScale = theScale;
 }
 void fireBullet(float mousePositionX, float mousePositionY)
 {
     Vector2 position = new Vector2(mousePositionX, mousePositionY);
     position = Camera.main.ScreenToWorldPoint(position);
     GameObject bullet = Instantiate(PlayerBulletGO, transform.position, Quaternion.identity) as GameObject;
     bullet.transform.LookAt(position);
     Debug.Log(position);
     //bullet.rigidbody2D.AddForce(bullet.transform.forward * 10);
     bullet.GetComponent<Rigidbody2D>().AddForce(bullet.transform.forward * 10);
 }
Please help me.
Answer by NoseKills · Jul 20, 2016 at 06:01 AM
Your fireBullet method
 void fireBullet(float mousePositionX, float mousePositionY) {}
Your fireBullet call
 fireBullet();
Just like the error says, there is no fireBullet method that takes 0 arguments. You have to feed in the x and y or make a version of the method that doesn't need the parameters.
Your answer
 
 
             Follow this Question
Related Questions
Unity 2d simple c# shooting script 1 Answer
C# 2D Shooting a bullet based on player direction 1 Answer
Finding target position for particle system based shooting 0 Answers
Bullet to Mouse Position? 1 Answer
Unity 2D bullet bounce 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                