Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by BlueBottom · Mar 31, 2013 at 10:20 AM · instantiateversionargument

I keep getting that "Instantiate" problem.

I keep getting the same error, can anybody help me by explaining why the problem appears, or at least give me the proper code?:

Assets/Scripts/TurretScript.js(72,17): BCE0023: No appropriate version of 'UnityEngine.Object.Instantiate' for the argument list '(System.Type, UnityEngine.Vector3, UnityEngine.Quaternion)' was found.

................................................................................................................................................................................. THE CODE:

function FireProjectile() { audio.Play(); nextFireTime = Time.time+reloadTime; nextMoveTime = Time.time+firePauseTime; CalculateAimError();

for(theMuzzlePos in muzzlePositions) { Instantiate (myProjectile, theMuzzlePos.position, theMuzzlePos.rotation); Instantiate (muzzleEffect, theMuzzlePos.position, theMuzzlePos.rotation); } }

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
1

Answer by whydoidoit · Mar 31, 2013 at 10:23 AM

For one of your instantiate calls you may have a script called myProjectile or muzzleEffect and it's using that rather than a variable that contains the prefab. Generally name your scripts using a capital letter to avoid this.

Another cause of this is defining variables like this:

    var somePrefab = GameObject;

When it should be like this:

    var somePrefab : GameObject;

You also need to assign the prefab in the inspector (which won't work with the first example!)

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 BlueBottom · Mar 31, 2013 at 12:39 PM 0
Share

Also, I get a problem, where the canon in my my game is supposed to shoot at an enemy, but it shoots the ground. Here's the whole script:

pragma strict

var myProjectile : GameObject; var reloadTime : float = 1f; var turnSpeed : float = 5f; var firePauseTime : float = .25f; var muzzleEffect : GameObject; var errorAmount : float = .001; var myTarget : Transform; var muzzlePositions : Transform[]; var turretBall : Transform;

private var nextFireTime : float; private var next$$anonymous$$oveTime : float; private var desiredRotation : Quaternion; private var aimError : float;

function Start () {

}

function Update () { if(myTarget) { if(Time.time >= next$$anonymous$$oveTime) { CalculateAimPosition(myTarget.position); turretBall.rotation = Quaternion.Lerp(turretBall.rotation, desiredRotation, Time.deltaTime*turnSpeed); } if(Time.time >= nextFireTime) { FireProjectile(); } } } function OnTriggerEnter(other : Collider) { if(other.gameObject.tag == "Enemy") { nextFireTime = Time.time+(reloadTime*0.5); myTarget = other.gameObject.transform; } } function OnTriggerExit(other : Collider) { if(other.gameObject.transform == myTarget) { myTarget = null; } } function CalculateAimPosition(targetPos : Vector3) { var aimPoint = Vector3(targetPos.x+aimError, targetPos.y+aimError,targetPos.z+aimError); desiredRotation = Quaternion.LookRotation(aimPoint); }

function CalculateAimError() { aimError = Random.Range(-errorAmount, errorAmount); }

function FireProjectile() { audio.Play(); nextFireTime = Time.time+reloadTime; next$$anonymous$$oveTime = Time.time+firePauseTime; CalculateAimError();

for(the$$anonymous$$uzzlePos in muzzlePositions) { Instantiate ( myProjectile, the$$anonymous$$uzzlePos.position, the$$anonymous$$uzzlePos.rotation); Instantiate ( muzzleEffect, the$$anonymous$$uzzlePos.position, the$$anonymous$$uzzlePos.rotation); } }

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

11 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

Related Questions

Checking if object intersects? 1 Answer

PhotonNetwork.Instantiate Argument Error. 1 Answer

Multiplying GUIs 0 Answers

How do you make the waypoint system work for objects instantiated? 2 Answers

Using a top level variable in a class 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