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 RoR · Feb 04, 2011 at 10:02 AM · instantiatechild

Help with local/world positiong a new gameobject

Trying to understand child and its position inthe world but under a parent.

So I have a Player , who has a spawn point infront of him as a child.

I use this spawn point to spawn bullets coming from his forward direction, but when i do that it ends up in the wrong area and i'm guesing it's to do with local and world?

GameObject star = (GameObject)Instantiate(Resources.Load("Bullet"));
star.transform.position = player.transform.FindChild("starSpawnPoint").transform.position;

EDIT--- So when I try to get an object to take the position of another object. It dosen't spawn correctly to that position.

 star = (GameObject)Instantiate(Resources.Load("NinjaStar"),GameObject.Find("starSpawnPoint").transform.position,Quaternion.identity);

This code does work and the sphere does end up at 0,0,0.

GameObject go = (GameObject)GameObject.CreatePrimitive(PrimitiveType.Sphere);
    go.transform.position = Vector3.zero;
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 runevision ♦♦ · Feb 04, 2011 at 10:06 AM 0
Share

Your code looks fine. It's hard to say what the problem is without having more detail. What is the pattern to where the bullets end up? Is it always at the same location in the world, or always at the same position relative to the player?

avatar image RoR · Feb 04, 2011 at 10:10 AM 0
Share

The player never moves the camera is locked on from a angled down view of the player. And THe bullets do end up at the same place each time.

1 Reply

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

Answer by Borgo · Feb 04, 2011 at 11:32 AM

Try to see in your moddeling software if your model are in the middle of the scene.

In Unity just put your bullet model in the scene, let it alone, without parent and set the positions to 0,0,0, if it isn't in the center of the world scene, so, your model are out of align.

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 RoR · Feb 04, 2011 at 03:26 PM 0
Share

So I went ahead and put a script to add a primitiveshape at the 0.0.0 location. Which it does show up at 0,0,0 and it shows up under my player cause my player is also position on 0,0,0.

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

No one has followed this question yet.

Related Questions

Attaching Object as child at certain point in animation 2 Answers

Prefab, procedural attachment of child, childCount return 0 1 Answer

Instantiate and Scaling 0 Answers

Create Clones as children in loops? 1 Answer

Instantiate as a Child of the Parent 4 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