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 berndtmiklos · May 17, 2021 at 07:38 AM · falling

Bomb falling from a plane is following the movement of the plane, why?

I've created a plane the is moving on the x axis. I instantiate a bomb falling from the plane so, that the transform.position of the plane equals to the instantiating position of the bomb. Then the bomb, instead of just falling, follows the flane on the x axis while falling. How to make the bomb fall with 0 movement on the x axis? My code:


bombSpawn.position = transform.position; 
bool fire = Input.GetKeyDown("space");
if (fire == true && checkBomb == false) 
{
    bombExisting = Instantiate(Bomb, bombSpawn);
    checkBomb = true;
}
Vector3 bombPosition = bombExisting.transform.position;
if (bombPosition.y < -2.8f)
{
    Destroy(bombExisting);
    checkBomb = false;
}

Comment
Add comment · Show 1
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 andrew-lukasik · May 17, 2021 at 07:43 AM 0
Share

Because Instantiate( prefab , transform ) is equivalent to:

 var go = Instantiate( myPrefab , myTransform );
 go.transfrom.parent = myTransform;

Use this instead:

 bombExisting = Instantiate( Bomb , bombSpawn.position , bombSpawn.rotation );

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Ambervandinther · May 17, 2021 at 07:59 AM

Is it possible you made the bomb a child of your parent plane?

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
1

Answer by Mrpxl · May 17, 2021 at 08:13 AM

Here by instantiating your bomb and setting the second parameter as bombSpawn, you are setting that bombSpawn as the parent of your bomb. See Transform.parent That is why it will follow the plane since that bombSpawn Transform moves with the plane. What you should do instead is:

 bombExisting = Instantiate(Bomb, bombSpawn.position, bombSpawn.rotation);

or:

 bombExisting = Instantiate(Bomb);
 bombExisting.position = bombSpawn.position;

Here you instantiate the Bomb without setting any parent and it will for sure work now!

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
1

Answer by berndtmiklos · May 17, 2021 at 07:01 PM

Thank you! That solved it! I didn't know about parent-child relations between the gameobjects.

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

119 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

zombies and the player SUDDENLY(not a beginning but a middle of playing) falling down 1 Answer

Adding falling and landing animations to the Locomotion System 1 Answer

falling through the terrain 0 Answers

Endless "Falling in place" Simulation Question 0 Answers

Adding Jumping and Falling Animations 0 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