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 TheRichardGamer · Dec 23, 2013 at 04:54 PM · textureraycastbulletdecal

How to stop textures flickering

When I instantiate a bullet hole on a cube it starts flickering and this is something that I find unpleasant for my game, but when I instantiate a bullet hole on a rounded surface, like a capsule, it doesn't flicker. So how do I fix this? Here's what I mean: http://videobam.com/LcUNs

Here's my script:

 var Barrel : RaycastHit;
 
 var Cam : Camera;
 
 var BulletHole : GameObject
 
 function Update () {
 
 hitRotation = Quaternion.LookRotation(Barrel.normal, transform.up);    
 
 
 
 }
 
 
 function Shoot () {
 
 if(Physics.Raycast(transform.position, Cam.transform.forward, Barrel, 60)){
 
 yield WaitForSeconds(0.1);
  var newBulletHole = Instantiate(BulletHole, Barrel.point, hitRotation);
        newBulletHole.transform.up = Barrel.normal;
        CurrentAmmo -= 1;
        print("The ammo of the MTAR is " + CurrentAmmo);
        newBulletHole.transform.parent = Barrel.transform;
        
    if(Barrel.transform.tag == "Player"){
    
    Barrel.rigidbody.AddForce(Cam.transform.forward * BulletImpactForce);
        
            }    
            
            if(Barrel.transform.tag == "Detail"){
    
    Barrel.rigidbody.AddForce(Cam.transform.forward * BulletImpactForce);
        
            }  
            
            
            
    
    
        }
 
 
 }
 
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by william9518 · Dec 23, 2013 at 06:11 PM

Make the bullet hole prefabs SLIGHTLY in front of the cube. The reason it is flickering is because it is actually half in and half out of the cube, and it does not flicker on a curved surface because if you think about it, the surface curves away from the prefab so it is not actually inside the sphere. Move it slightly in front of the cube, like 0.001 would be enough.

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 TheRichardGamer · Dec 25, 2013 at 03:27 PM 0
Share

Well, how would I do that? Because no matter what I do, it returns an error like "Operator '-' cannot be used with a left hand side type of 'UnityEngine.Vector3' and a right hand side type of 'float'."

I'm basically trying "newBulletHole.transform.up -0.001;"

But I guess that's not possible.

avatar image
0

Answer by Sarmad123 · Nov 01, 2017 at 12:17 PM

you can override your position just by writing this line to stop flicking Barrel.point = new Vector3 (Barrel.point.x - 0.001f,Barrel.point.y - 0.001f,Barrel.point.z - 0.001f);

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 AidanHorton · Nov 01, 2017 at 12:42 PM 0
Share

This question is from 2013 O.o

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

21 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

Related Questions

Parenting Bullet Holes? 1 Answer

Adding bullet holes to walls 3 Answers

Checking material on raycast 1 Answer

ContactPoint with OnParticleCollision? 0 Answers

How can I can I cast a ray from a gameobject? 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