Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by shadowpuppet · Mar 25, 2019 at 08:49 PM · instantiate prefab

trouble instantiating rocket from plane

My game has a number of instantiated projectiles...I lob arty shells, shoot bazooka rockets as well as shoot rockets from a moving boat ( medium to slow moving boat). But now I have a plane in my game and I can not get rockets to shoot like I was hoping. If I am on the ground it all works. But once I get some speed for take off or in the air the bullets fire backwards. I have cranked up the Dist to like 10000 and it may be working but it happens so fast I can't see it. The projectile is just a sphere with a rigidbody - not kinematic, no constraints, no gravity. They also behave weird when I do find that "perfect" velocity where I can actually see the rocket ( though barely traveling forward) it jitters all over the place as if it is still somehow connected to my plane. It isn't - at least not in the inspector, they are instantiating as separate gameObjects. Any answers for this one or work arounds so I can use my plane for battle and not just transportation??

             GameObject myGrenade = Instantiate(grenade,  Muzzle.position,transform.rotation)as GameObject; 
             myGrenade.GetComponent<Rigidbody>().AddForce (transform.forward *Dist);
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Alex_May · Mar 25, 2019 at 10:57 PM

Are the bullets going backwards, or just a lot slower than the plane? Try to set the velocity of the bullets to the plane's velocity after you spawn them.

Also check the rockets are not set to collide with the plane in your collision matrix. They should be on different layers.

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 shadowpuppet · Mar 26, 2019 at 12:31 AM 0
Share

the bullets were going forwards. as my plane sped up I could see the gradual difference in forward thrust of the rocket as they went slower and shorter until,finally backwards. But I lowered the speed of my plane - although it seems to be an arbitrary number in that 60 for my plane doesn't seem any slower visually than 120. This seemed to fix everything getting rockets flying correctly. I also added a trail renderer to the rocket for .15f to give it a bit of a trail so I can see it and was able to knock off a lot of the speed for the rocket. Because of the lag I actually instantiate the rockets well below and ahead of my plane - or at least that is the spawn point but they appear to be co$$anonymous$$g out of the wings with the trail renderer and from the camera perspective. But thanks for the response. I don't get many

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

167 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 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

Instantiating UI Prefab - Error: Setting parent of a transform which resides in a prefab is disabled. What's wrong with my code? 1 Answer

Instantiated at wrong position 2 Answers

How to use Button.OnClick.AddListener? 2 Answers

Destroying Instantiated Prefab in Another Script -- Can't destroy to prevent memory loss? 0 Answers

Invisible Prefab spawning at location of Player before being instantiated 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