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 bubzy · Aug 20, 2013 at 06:36 AM · instantiatepositionconfused

instantiated object not in right position

im trying to instantiate an object above my player (currently a cube) im using

temp = Instantiate(carry,transform.position + new Vector3(0,5,0),transform.rotation) as Rigidbody;

this works ok, but the instantiated object is always a few units to the left of the player. if I set the players position to 0,0,0 in the editor then press play, the inspector shows it to be -8,0,0.

bit confused here, both objects have rigidbody components attached, could it be something to do with that? or some localposition thing?

thanks in advance

Comment
Add comment · Show 4
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 Joyrider · Aug 20, 2013 at 06:51 AM 0
Share

Are you sure you don't have another script that is positionning your player?

avatar image bubzy · Aug 20, 2013 at 09:33 AM 0
Share

at work now, will check when I get back, thanks. pretty sure its just physics controlling it though.

avatar image clunk47 · Aug 20, 2013 at 06:21 PM 0
Share

Be sure both your player and your prefab are centered to their parents' positions.

avatar image bubzy · Aug 22, 2013 at 05:44 PM 0
Share

well, I couldn't work out how to change the centre of objects, but I cheated and made a blank gameobject and parented all the other bits to that, and put that in the centre, works ok, maybe theres some kind of tradeoff but currently, its doing the job, thanks for the pointers guys :)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by BuildIntoGames · Aug 22, 2013 at 05:51 PM

 var temp : GameObject;
 var positionBlock : GameObject;
 
 function Start () {
 temp = Instantiate(carry, positionBlock.transform.position ,positionBlock.transform.rotation);
 }

I'm not too sure this is what you want. Attach this script to an empty game object. Make the variable temp as the object you would like to clone. Create another game object and move it to where you want your clone to spawn. Then, make that block the variable positionBlock. On start, it will clone your object and put it in the position of the positionBlock.

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

18 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

Related Questions

Not instantiating prefab in the right place after 2017 update 2 Answers

Keep instantiated GameObject's position while parenting it to another GameObject 3 Answers

spawn muzzle flash with random rotation? 2 Answers

Instantiate at original transform 1 Answer

Instantiated object coordinates from code aren't the same as the coordinates from Inspector?,Inspector Coordinates not the same as GameObject.Find Coordinates? 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