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 RaptopLob · May 12, 2011 at 05:51 PM · animationinstantiatecoordinates

Instantiating multiple prefabs with animations all appear at 0,0,0

Hi

I was wondering if anyone had any insight into my problem.

I've created a prefab of a 2d wave with a simple animation attached. I want to create a number of them in a row to create a curtain along the bottom of my screen, however they all appear at the center of the world, rather than the position along the X axis that I specify...

My simple enough code is:

var seaPrefab : GameObject; var counter: int = 0; var depthVariable: int = 0.2;

function Update () {

 if(Input.GetAxis("Horizontal")){

     var seaLayerInstance : GameObject = Instantiate(seaPrefab, Vector3(counter*2, 0, depthVariable), transform.rotation);

     counter++;
     depthVariable *= -1;

 };

};

I've also put my animated prefab inside an empty GO hoping to offset the prefabs that way, but that has also not worked.

Any help would be greatly appreciated!!

Cheers,

Rob

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
0
Best Answer

Answer by RaptopLob · May 20, 2011 at 01:07 PM

The problem was I wasn't using the prefab as a child of an empty GO as I had attempted to do.

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 Jeston · May 12, 2011 at 08:41 PM

Check the inspector to make sure your world units are far enough apart. Have you tried something like:

seaLayerInstance.transform.position = Vector3(....);

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 Owen-Reynolds · May 12, 2011 at 11:51 PM

Input.GetAxis("Horizontal") does not allow you to pick a position. It is always between -1 and 1, and represents how long you have been holding down Left/Right arrow (1 means you've held Right-arrow long enough to be sliding or turning at full speed.) It's for moving the player.

This Unity doc has an example of making a wall, in Start. Could adapt it for your line: http://unity3d.com/support/documentation/Manual/Instantiating%20Prefabs.html

Also, depthVariable should be a float (since you're using 0.2.)

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

1 Person is following this question.

avatar image

Related Questions

Have an object play an animation where it is instantiated. 1 Answer

Can I make animations snap to a frame? 1 Answer

creating Humanoid Motion from XYZ coordinates 0 Answers

Random.onUnitSphere Hemisphere? 2 Answers

How do you run a line of code after an animation is finished playing,I am trying to fire an arrow at the end of the bow attacking animation 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