• 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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

Checking material on raycast 1 Answer

Parenting Bullet Holes? 1 Answer

Adding bullet holes to walls 3 Answers

Using Raycast to shoot a bullet sometimes goes through objects 0 Answers

Assigning UV Map to model at runtime 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges