Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Raycast, Bullet Holes, and Stairs

Discussion in 'Scripting' started by B1ackSmoke93, Jan 8, 2013.

  1. B1ackSmoke93

    B1ackSmoke93

    Joined:
    Dec 2, 2012
    Posts:
    4
    Hello all, this is my first post so apologies if I don't make too much sense.
    I'm following with ETeeskiTutorials and got stuck on video FPS1.13 Raycasts and Bullet Holes (https://www.youtube.com/watch?v=cZsG4dfCUec)

    Here is a video I recorded showing and explaining my problem -


    Update: So it seems that the bullet holes are only showing up on one side of all the levelparts.

    My bullet holes aren't aligned with my gun sights when zoomed in or even when I hip fire it seems way off.
    At first I thought my gun was not aligned or something, but then I realized that the wall and some cubes were the only objects that the bullet holes showed up on.

    Another small issue I've been having is that when I go to walk up a slope I slow way down. Is this because of it's too steep or is it something to do with my settings, or both?

    Any help would be appreciated,
    -B1ackSmoke93
     
    Last edited: Jan 8, 2013
  2. eteeski

    eteeski

    Joined:
    Feb 2, 2010
    Posts:
    476
    It looks like the position and rotation of your bullet spawn object is off. It looks like you might actually have the bullet spawn not a child of the right game object. In the top left hand corner of unity, there's a button that either says global or local. set it to local. then select your bullet spawn object and make sure it's positioned at the front of your gun and the blue arrow is forward (in the direction you want the bullets to go). Also, make sure the bullet spawn is a child of the game object with the gun script attached to it.
     
  3. B1ackSmoke93

    B1ackSmoke93

    Joined:
    Dec 2, 2012
    Posts:
    4
    Hey ETeeski thanks for the response!

    I double checked all of that and it seems that I have done all of it correctly. It wouldn't be as puzzling if the bullet holes would appear on all sides of the objects. Would it help if I made a video of my unity project and showed all the different windows/gameobjects?
     
  4. B1ackSmoke93

    B1ackSmoke93

    Joined:
    Dec 2, 2012
    Posts:
    4
    Alrighty, so I went back and did fps1.12 and fps1.13 again and voila it works! I'm sure I messed up a bit with parenting some of the objects, also I messed up on one line of code.
    Instead of putting:
    Code (csharp):
    1. Instantiate(bullet,bulletSpawn.transform.position, bulletSpawn.transform.rotation);
    I accidentally wrote bullet.transform.rotation instead of bulletSpawn.

    The only issue I see as of now is that when shooting high up on a wall the bullet holes don't seem to appear as often, I have to move the gun around rapidly for some bullet holes to appear, but when I'm about halfway down the wall and below the bullet holes show up fast as they should.

    Update: It seems to happen on and off, but any wall that I shoot at it looks like the bullet holes will skip sometimes. This especially happens when I aim up high. Sometimes bullets just wont show up higher up on the wall unless I get really close to it.
     
    Last edited: Jan 9, 2013