• 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 MC HALO · Aug 17, 2011 at 04:20 AM · decal

Decal help please :)

Hey Guys i just made a script which shoots at a object with a rigid body and applies force to it. I just started to make it leave a decal once i shoot but it shows no decal when i shoot :) can you please help me with this thank you :)

here is the script :

var woodPartical : Transform;


 function RayShoot (){
 
     GameObject.Find("m1911pistoleReloadandShooting").animation.Play("Shoot");
         var hit : RaycastHit;
 
                 var DirectionRay = transform.TransformDirection(Vector3.forward);
                 
                 Debug.DrawRay(transform.position , DirectionRay * Range , Color.blue);
                 if(Physics.Raycast(transform.position , DirectionRay , hit, Range)){
                 
                 var rotation = Quaternion.FromToRotation(Vector3.forward, hit.normal);
 
                     var collided = hit.point;
                     
                 if(hit.rigidbody){
                 
                 hit.rigidbody.AddForceAtPosition( DirectionRay * Force , hit.point);
                 
                 if(hit.transform.tag == "Enemy"){
                 
                 var Woodpar = Instantiate( woodPartical, collided , rotation);
                 
                 Woodpar.transform.parent = hit.transform;
                     
                     
                 
                 }
                     hit.collider.SendMessageUpwards("ApplyDamage" , damage , SendMessageOptions.DontRequireReceiver);
                 }
                 
                 
                 }
                 
                 BulletsLeft --;
                 
                 if(BulletsLeft < 0){
                 
                 BulletsLeft = 0;
                 
                 }
                 
                 if( BulletsLeft == 0 ){
                 
                 Reload();
                 
                 
                 }
                 
                 }
     

please do remember that i have only given the part that makes the script shoot :) thank you in advance MCHALO

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
2
Best Answer

Answer by roamcel · Aug 17, 2011 at 05:20 AM

Besides the fact that you don't seem to be instantiating a decal (2d texture), but a 'particle' prefab, your code should work all right for what I see.

I suggest you change your 'woodPartical' prefab in the inspector with a SPHERE mesh primitive of adequate dimensions (usually the default 1 sized primitives are well visible on the scene). If the sphere appears on hit, then it's clearly your 'woodPartical' prefab the culprit. If the sphere doesn't appear, there could be a simple layer assignment issue to check (assure that the camera is actually culling or not the particle effect layer).

Comment
Add comment · Show 3 · 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 MC HALO · Aug 17, 2011 at 08:54 AM 0
Share

hey thanks for the advice it was my fault i had placed the Partical in the wrong place lmao and it would not work properly :) thanks by any chance do you know how to make a very simple decal system for example if you it this object tagged etc produce this bullet mark?

thank you one again :)

avatar image roamcel · Aug 17, 2011 at 09:32 AM 0
Share

You're welcome. I never tried decals yet, however I'm pretty sure a common way of implementing them is through PROJECTORS, and I'm pretty sure that you'll easily find examples if you search in that direction.

avatar image MC HALO · Aug 17, 2011 at 11:29 AM 0
Share

yea thats a really good idea :)

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Adding bullet holes to walls 3 Answers

projectors vs. textures on plane with alpha channels 1 Answer

Bullet hole attach to movable object? 1 Answer

How do I wrap blood decals around meshes that are not just a flat plane? (e.g. blood spatter on a round lamp) 0 Answers

Realtime Skin Mesh Decals 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