Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Bug Transform Forward not working properly when rotating character (lean)

Discussion in 'Physics' started by imjustthatguy1, Dec 11, 2022.

  1. imjustthatguy1

    imjustthatguy1

    Joined:
    Apr 23, 2018
    Posts:
    27
    Hello

    I have a character that fires projectiles with the ability to lean through the quaternion lerp function. When I fire the projectile, it uses the transform forward of the projectile transform position as the origin of which to fire the projectile from.

    This works fine until I lean, when I lean, notably when I aim upwards (along y axis Im guessing), the projectiles fired are not in line with where it should be going (projectiles land well below the transform forward of the position).

    To make matters worst, when firing the projectiles in rapid succession, a projectile would occasionally land at the respective position its supposed to go.

    What can possibly be wrong with my script? The projectile position is a child of the rotation of the character that drives the lean mechanic. I've tried all sorts of methods to no avail.

    This is the code I use for configuring the velocity of the projectile, the ItemUsePointTransform.forward is the transform of which the projectile is fired from
    upload_2022-12-11_13-42-22.png

    Similar threads

    https://forum.unity.com/threads/shoot-mechanic-in-unity-transform-forward-not-working.1111771/
    https://answers.unity.com/questions/1673024/transformforward-inaccurate.html
     
  2. imjustthatguy1

    imjustthatguy1

    Joined:
    Apr 23, 2018
    Posts:
    27
    Ive tried gizmos for drawing the ray, the ray displays the correct information of drawing where the projectile lands, but it is still not accurate. Again, about ~5% of the time, a projectile will land at the correct location, there is no projectile spread / inaccuracies involved, and only occurs while leaning
     
  3. imjustthatguy1

    imjustthatguy1

    Joined:
    Apr 23, 2018
    Posts:
    27
    Just updated editor version from 2021.3.5f1 -> 2021.3.15f1, bug is still here