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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Bullet path off slightly

Discussion in '2D' started by stockhouse50, Sep 19, 2015.

  1. stockhouse50

    stockhouse50

    Joined:
    Apr 9, 2015
    Posts:
    14
    I am creating a overhead view of a tank. It is composed of 4 parts: a 3D cube object as the tank body, a cube scaled to be a long thin barrel, another cube to act as the pivot for the barrel and an empty object for the bullet instantiation point. The tank body is the parent while the pivot is the child. The barrel is then a child of the pivot. Basically the tank can move up/down/side to side with the key and the pivot has a script attached so it can rotate around with the barrel attached to face towards the mouse cursor.

    The movement and rotation works fine. The problem is when I left click and fire the bullet. The bullet sometimes fire straight out from the barrel but as I rotate and fire in some spots the bullet path will be slightly off to the right. Now if I remove the tank body, I can rotate the pivot/barrel and when I fire the bullet path is perfectly fine. I tried recreating the tank body and still had the same issue. Why does the tank body cause the bullet path to be off ?? Thanks in advance.

    Not sure if this is code related or something else.
    tank.png
     
  2. alijib

    alijib

    Joined:
    Nov 14, 2014
    Posts:
    17
    Check if your Bullet/Bomb prefab positions are exactly 0,0,0 , then try again.
     
  3. stockhouse50

    stockhouse50

    Joined:
    Apr 9, 2015
    Posts:
    14
    Hi, thanks for the reply. I set them to 0,0,0 and still have the same issue. Not sure why adding the pivot/barrel to the tank body causes this change in bullet path. Also the barrel morphs but stays same size without tank body.
     
  4. alijib

    alijib

    Joined:
    Nov 14, 2014
    Posts:
    17
    the barrel is getting skewed some how. And i think that skewing is responsible for projectile offset.
    Post your script too. someone will be able to help you out.
     
    tedthebug likes this.