• 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 · Apr 29, 2020 at 02:42 PM · instantiate prefab

Instantiate explosion on fast moving object

I know the basics of instantiating a prefab. My code works in that when the rocket hits a wall , an explosion is instantiated. The problem is that my rocket is moving so fast that the explosion seems to "lag" and rather than the explosion taking place on the surface of the object it hits, it explodes more inside the object. So I am thinking what I want to do is OnTriggerEnter, get the EXACT location of where the rocket made contact ( a Vector3?) and instantiate the explosion there rather than the rocket location which is several feet further along its path. But I can't seem to get the explosion to instantiate at a Vector3 location. Any ideas?

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 shadowpuppet · Apr 29, 2020 at 02:46 PM 0
Share

I mean I need to somehow mark the position of where the rocket makes initial contact with target and instantiate explosion on that mark rather than on the rocket object. Either that or slow the rocket down - which works but doesn't really feel or look right

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by shadowpuppet · Apr 29, 2020 at 09:05 PM

@streetwalker. I like the raycast idea as can tweak the distance cast with rocket speed so could detect the wall a bit early and explode as hits wall/object. This is an old project that I have fiddled with off and on for a few years. Virus lock down has me picking it up again and debugging. The rocket thing was annoying because all the cool visuals were behind a wall. I'm going to play with the raycast . Thanks

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 streeetwalker · Apr 29, 2020 at 06:34 PM

Hi @shadowpuppet, you can the rocket collider's method, ClosestPointOnBounds(transform.position) in OnTriggerEnter to get a point. See the unity documentation on that.

It seems you have another problem - you can't instantiate the explosion? We'd need to see your setup and code.

Comment
Add comment · Show 2 · 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 · Apr 29, 2020 at 06:48 PM 0
Share

no, I can instantiate the explosion just fine, it's just that the rocket speed is 4500 and the explosion that gets instantiated in rockets position a frame later is beyond the point of impact. It explodes , but in the case of ...a wall, for instance, rather than see the explosion effects on the front of the wall they take place on the other side of the wall. An easier fix was I simply lowered the rocket speed to 1500. visually the rocket seems to travel nearly as fast - or at least fast enough to feel like a rocket - and explodes on impact much closer to front side of wall. I had the rocket speed cranked up so high for use in a fast moving vehicle so the rocket needed to have that extra boost or it would travel just barely faster than the moving vehicle from which it was fired. I have since disabled that so rockets only come from a person walking so was able to dial down the velocity of the rocket to where it works and explodes as desired - at the point of impact and not 4 feet further down the rockets path behind the target

avatar image streeetwalker shadowpuppet · Apr 29, 2020 at 06:57 PM 0
Share

@shadowpuppet, I know what you mean. You can also try setting a different collision detection method on your Rigidbody - there are several in the inspector and one of them might do a better job as well in combination with that Bounds code.

An alternative method is to do a RayCast along the z axis of your rocket - assu$$anonymous$$g z is forward, to deter$$anonymous$$e where it hit's the edge of the collider - you can get the hit point from that.

This is a common problem and you'll find quite a few discussions about it.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

198 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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 at a specific location? 0 Answers

How to Instantiate platforms with certain space inbetween each platform (Endless Runner) 0 Answers

turret shoot in direction and hit my health (scripts attached,i need to know how to put it together) 0 Answers

Instantiated Prefab not Moving 1 Answer

Why do my first 50 instances of a prefab have the same properties? 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