Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by yeoldwarchap · Jul 20, 2016 at 04:17 AM · c#2dmouseshootingbullet

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

214 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges