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 Miso21 · Mar 01, 2018 at 09:38 AM · errorinstantiatebulletoverload

I need help with instantiate - Overloads

theres 2 errors which says : the best overloaded method,argument #3 cant convert...

      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
 
  public class bulletDestruction : MonoBehaviour {
 
     public GameObject particleEffect;
     public Transform particleSpawn;
 
 
     void OnCollisionEnter()
     {
         Destroy ();
     }
     
     void Destroy()
     {
         Instantiate (particleEffect,particleSpawn,particleSpawn.rotation);
         Destroy (gameObject);
     }
 }
 
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

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by meat5000 · Mar 01, 2018 at 10:01 AM

You should not create a Function with the name of an existing method. Destroy already exists and you may well confuse the compiler by calling Destroy(object) from within a function called Destroy(). You are redefining the function so to speak. You also need to reference the transform position for your Vector3 and not the whole Transform.

 void OnCollisionEnter()
      {
          DestroyGO ();
      }
      
      void DestroyGO()
      {
          Instantiate (particleEffect,particleSpawn.position,particleSpawn.rotation);
          Destroy (gameObject);
      }

If you look at Instantiate in the scripting API youll see at the top of the page a list of 5 versions of Instantiate. These are 'Overloads' and you must match one of those patterns. It is this to which the error specifically refers. You can see that as Argument #2 in your Instantiate is actually referring to Transform. As a result it looks at the list of Overloads and picks the one this currently fits. This would either be #3 Nothing or #3 bool instantiateInWorldSpace as that's what is in the Overloads that have the pattern 'Instantiate(Object,Transform' . When it sees the rotation it gets confused and can no longer find a matching Overload, hence why it says #3.

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
avatar image
0

Answer by upasnavig90 · Mar 01, 2018 at 09:56 AM

https://docs.unity3d.com/ScriptReference/Object.Instantiate.html

instead of rotation u need to use quaternion. public void Instantiate(Object original, Vector3 position, Quaternion rotation);

Comment
Add comment · Show 1 · 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
avatar image Xpartano · Mar 01, 2018 at 10:00 AM 0
Share

And also he has to use Position and not Transform as he is using! ;D

avatar image
0

Answer by HeresJohnny123 · Mar 01, 2018 at 10:01 AM

The problem i can see is that you are using particlespawn to set the place where to spawn the object. But it's asking for a vector and not a transform.

Meaning that the instantiate part should look like this:
Instantiate (particleEffect,particleSpawn.position,particleSpawn.rotation);

Since transform.position = vector

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

119 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

Related Questions

randomly shoot using number generator 0 Answers

Bullets are firing in the wrong direction. 1 Answer

Moving a spawned shuriken 2 Answers

Time between bullet shots increasing each time? 0 Answers

Instantiate() Argument error 1 Answer


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