Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 smirlianos · Oct 27, 2013 at 09:38 AM · raycastvector3fpsdecal

Instantiated bullet hole has wrong rotation

Hello,

I have this script that Instantiates a bullet hole when a raycast hits something. The problem is it Instantiates on wrong rotation, so it doesn't actually look like a hole on the wall. Any help??

 var hit : RaycastHit;
         if (Physics.Raycast (transform.position, fwd, hit, attributes.Range))
         {
             print ("We hit something!");
             Instantiate(Hole, hit.point, Quaternion.FromToRotation(Vector3.forward, hit.normal));
         }
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
Best Answer

Answer by jonnyhopper · Oct 27, 2013 at 10:18 AM

It's hard to say without seeing the prefab (can you post a screenshot of the error?)

But, have you tried using transform.forward or transform.up instead of Vector3.forward in the Quaternion rotation?

Comment
Add comment · Show 4 · 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 smirlianos · Oct 27, 2013 at 10:36 AM 0
Share

The hole is just a Unity pre-build plane with a texture on it.

Here's a screenshot with the problem: alt text

avatar image jonnyhopper · Oct 27, 2013 at 10:41 AM 2
Share

Right, I see. Try using Quaternion.LookRotation( hit.normal) or after it's instantiated, just set transform.up = hit.normal on the instantiated object.

avatar image Ishidres jonnyhopper · Jun 07, 2020 at 12:59 PM 0
Share

Right, I see. Try using Quaternion.LookRotation( hit.normal) or after it's instantiated, just set transform.up = hit.normal on the instantiated object.

Thank you so much! It perfectly works! :)

avatar image smirlianos · Oct 27, 2013 at 10:46 AM 0
Share

Thanks man, it worked! :)

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

17 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

Related Questions

issue with bullet hole decal 1 Answer

Raycast Decals,Sound and MuzzleFlash not working too well 0 Answers

Raycast not pointing correctly with a custom Vector3 2 Answers

character wont rotate and is stuck to the one position. 0 Answers

wheel script raycast 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