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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by DezC · Sep 13, 2012 at 05:34 PM · instantiatetransformobject

'transform' is not a member of 'Object' code problem

I'm currently trying to do a basketball game where the basketball instantiates at a certain position after the player presses the "shoot" key. The problem is I get this error message when compiling 'transform' is not a member of 'Object'

Here's the code:

 var newball;
 
 static var tempBasketBall: Rigidbody;
 
 var pos: Transform[];
 
 var ball1: Rigidbody;
 var ball2: Rigidbody;
 var ball3: Rigidbody;
 
 var canControl1 = true;            
 var canControl2 = true;
 var canControl3 = true;
 
 var destroyTime: int = 6;        
 
 var player1: GameObject;        
 var player2: GameObject;
 var player3: GameObject;
 
 var b1Parent: Transform;        
 var b2Parent: Transform;
 var b3Parent: Transform;
 
 var yVelocity: float;            
 var zVelocity: float;            
 
 
 function Start () 
 {
     ball1 = Instantiate(tempBasketBall, pos[0].position, pos[0].rotation);
     ball2 = Instantiate(tempBasketBall, pos[1].position, pos[1].rotation);
     ball3 = Instantiate(tempBasketBall, pos[2].position, pos[2].rotation);
 }
 
 function Update () 
 {
     if(Input.GetButtonUp("Player1") &&canControl1)
     {
         ball1.useGravity = true;
         ball1.velocity = transform.TransformDirection(0, yVelocity, zVelocity);
         MakeBall1(pos[0]);
         canControl1 = false;
     }
 }
 
 function MakeBall1(pos)
 {
     yield new WaitForSeconds(1);
     ball1 = Instantiate(tempBasketBall, pos.transform.position, pos.transform.rotation);
     
     canControl1 = true;
 }


The error points out to the instantiate section of the MakeBall1 function. How do I fix this? Help

Thanks in advance

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 PProductions · Sep 13, 2012 at 05:41 PM

 var pos: Transform[];

 ball1 = Instantiate(tempBasketBall, pos.transform.position, pos.transform.rotation);

These are your problems, pos is an array and this means you must give an index to use it's values. Also you don't need to use .transform as pos is already a transform. Here is an edited version, replace [i] with whatever index of the array you wish to use

 ball1 = Instantiate(tempBasketBall, pos[i].position, pos[i].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 DezC · Sep 13, 2012 at 07:16 PM 0
Share

Thank you for the response. I tried your suggestion, it seems to be giving me a new error message. It says "Type 'Object' does not support slicing". How do I fix this?

Thanks

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

10 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

Related Questions

Trying to get a shoot function working in unity using instantiate and it isn't working. 1 Answer

Instantiate Object at the extreme end of the object 0 Answers

How are you able to use a Transform argument for Instantiate? 2 Answers

Putting prefab into scene messes with the transform origin? 1 Answer

Instantiate Problem 2 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