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 DA_ATeam · Nov 13, 2011 at 11:53 PM · iosinstantiatetransformslicing

Slicing Not Supported/Transform Not a Member Disaster

I just successfully completed a trial web version of my new Unity project. It works fine. The final deliverable however is an IOS platform game. Problem is, some of the web version code does not seem to translate to well to IOS. Here is my 'good' web player code.

var newball; static var tempBasketBall :Rigidbody;

var pos :Transform[0];

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 yVel :float; var zVel :float;

function Start()

{ ball1 = Instantiate (tempBasketBall, pos[0].position, pos[0].rotation); ball1.transform.parent = b1Parent;

 ball2 = Instantiate (tempBasketBall, pos[1].position, pos[1].rotation);
     ball2.transform.parent = b2Parent;
 
 ball3 = Instantiate (tempBasketBall, pos[2].position, pos[2].rotation);
     ball3.transform.parent = b3Parent;
 

}

function Update() { if(Input.GetButtonDown("Player1") && canControl1) { player1.animation.PlayQueued("aim"); }

 else if(Input.GetButtonUp("Player1") && canControl1)
 {
     player1.animation.PlayQueued("fire");
     ball1.transform.parent = null;
     ball1.useGravity = true;
     ball1.velocity = transform.TransformDirection(0, yVel, zVel);
     MakeBall1(pos[0]);
     DestroyBall(ball1);
     canControl1 = false;
     player1.animation.PlayQueued("idle");
 }
 
 if(Input.GetButtonDown("Player2") && canControl2)
 {
     player2.animation.PlayQueued("aim");
 }
 
 else if(Input.GetButtonUp("Player2") && canControl2)
 {
     player2.animation.PlayQueued("fire");
     ball2.transform.parent = null;
     ball2.useGravity = true;
     ball2.velocity = transform.TransformDirection(0, yVel, zVel);
     MakeBall2(pos[1]);
     DestroyBall(ball2);
     canControl2 = false;
     player2.animation.PlayQueued("idle");
 }
 
 
 
 if(Input.GetButtonDown("Player3") && canControl3)
 {
     player3.animation.PlayQueued("aim");
 }
 
 else if(Input.GetButtonUp("Player3") && canControl3)
 {
     player3.animation.PlayQueued("fire");
     ball3.transform.parent = null;
     ball3.useGravity = true;
     ball3.velocity = transform.TransformDirection(0, yVel, zVel);
     MakeBall3(pos[2]);
     DestroyBall(ball3);
     canControl3 = false;
     player3.animation.PlayQueued("idle");
 }
 
 

}

function MakeBall1(pos)

{ yield new WaitForSeconds(1); ball1 = Instantiate(tempBasketBall, pos.transform.position, pos.transform.rotation); ball1.transform.parent = b1Parent; canControl1 = true; }

function MakeBall2(pos) { yield new WaitForSeconds(1); ball2 = Instantiate(tempBasketBall, pos.transform.position, pos.transform.rotation); ball2.transform.parent = b2Parent; canControl2 = true; }

function MakeBall3(pos) { yield new WaitForSeconds(1);

 ball3 = Instantiate(tempBasketBall, pos.transform.position, pos.transform.rotation);
 ball3.transform.parent = b3Parent;
 canControl3 = true;
 }
 function DestroyBall(ball:Rigidbody)
 {
     yield new WaitForSeconds(destroyTime);
     Destroy(ball.gameObject);
 }


I get a strange error saying add a semi colon at end when i add this code to my IOS build. Well clearly there is a semicolon there. It was suggested I get rid of the [0]....when I do that I get a, "BCE0048: Type 'UnityEngine.Transform' does not support slicing". If I get delete the slicing elements in the 'start function' I get this error; BCE0019: 'transform' is not a member of 'Object'. Removing 'transform' I get an error saying 'position' is not a member further degrading my control of the position of the instantiated new ball. How can I adapt this original code to work in IOS without giving up the position and transform of where the ball is to be cloned(the players Hand)? I butchered the code enough to make it compile, but the new ball instantiates at some arbitrary position and shoots from there, this is not acceptable. Any assistance would be greatly appreciated as I'm approaching a deadline and need to move pass this translation quirk.

Comment
Add comment · Show 2
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 Eric5h5 · Nov 14, 2011 at 04:27 PM 0
Share

Please use the format code button when you post code.

avatar image DA_ATeam · Nov 14, 2011 at 07:50 PM 0
Share

Ok! Sorry about the formatting, I guess a site that is very similar does the, indent code by 4 spaces thingy. Confusion on top of confusion! So sorry

1 Reply

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

Answer by Owen-Reynolds · Nov 14, 2011 at 04:17 PM

The first array should "officially" look like var pos : Transform[];. Says that pos will link up with some array, to be created later. The zero inside sort of says you want to create the array now, with zero things in it, before replacing it with the real array.

It's possible that your web platform ignored the zero inside -- but the iOS compiler is more strict about it. The missing semicolon message probably means "uh, I don't get this line, but if you moved the semicolon just after Transform, you could at least make the first part legal."

Comment
Add comment · Show 5 · 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 DA_ATeam · Nov 15, 2011 at 09:12 AM 0
Share

@Owen Reynolds Thanks man! That did clear up that first error. But the script is still not controlling where the ball is instantiated. Though the pos array for three players indicates that the right hand is the position and transform where the newball should clone, it creates it on the floor or units above his head and then changes positions the more one shoots. So it's not reading this setup at all. I've even made the ball a child of the right hand and it still creates it in some random position. Guess I'll scrap this template and start from scratch. If any one has any ideas on IOS instantiating from a defined position and shooting the projectile please let me know. I'm open to suggestions. Thanks

avatar image Owen-Reynolds · Nov 15, 2011 at 03:15 PM 1
Share

$$anonymous$$aybe try a fresh copy? Parents should have no initial effect on the position at all. But, makes the most sense not to make it a child of the hand. Once you throw it, you can't guide it like a sorceror.

avatar image DA_ATeam · Nov 15, 2011 at 08:29 PM 0
Share

I read an article on optimizing in Unity at about 4am. It stated to avoid using instantiation in IOS projects as it's quite expensive and can cause a 'hiccup'. $$anonymous$$aybe this is my hiccup, positioning! This article suggested that you use Spawn$$anonymous$$anager ins$$anonymous$$d. I don't think spawning is appropriate here. Of course I could be wrong. I'll look at instantiating on a simpler and lesser basis!

avatar image Owen-Reynolds · Nov 16, 2011 at 01:00 AM 0
Share

The "hicup" is the same as if you decided to perform 200 rayCasts in one frame. You'd see a tiny stutter as the frame rate momentarily fell. Won't affect anything besides that.

Getting rid of Instantiate is tricky if you don't already know how: create an array of three balls, offscreen and diabled somehow. Ins$$anonymous$$d of spawning, teleport the ball to where you were going to spawn it, wake it back up, and reset all the vars it uses. If you don't have a problem with frame-rate, don't bother.

avatar image DA_ATeam · Nov 16, 2011 at 01:30 AM 0
Share

@Owen Reynolds Thanks again for responding and hacking this issue out with me. Honestly I don't want to ditch it and try another setup. Its so close to working correctly and looks great. Location, location, position!!!! The app is simple and small enough that no major frame issues arise because of the instantiation. I'll maybe work on a different aspect of the game and come back to the instantiate part in a couple of days.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

iOS Instantiate transform as child -- positioning bug 2 Answers

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

Problem with GetComponentinChildren and Instantiate 0 Answers

how to spawn on random postion but non on static positions 0 Answers

How to follow multiple clones positions of an instantiate prefab having a velocity ? 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