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

Rotate barrel in revolver

Discussion in 'Scripting' started by Trekko, Aug 2, 2019.

  1. Trekko

    Trekko

    Joined:
    Jan 24, 2018
    Posts:
    21
    Hi!
    I'm makeing my first fps and decided to add revolver. But i have problem with reloading because I don't know how to rotate barrel after shoot.I tried to make it in animation but barrel back to old position. How to make it in script way?
     
  2. Trekko

    Trekko

    Joined:
    Jan 24, 2018
    Posts:
    21
    P.S.
    I also tried to use eulerAngles and localEulerAngles but every attempt failed. Barrel rotate in all dimensions but any isn't correct :/
     
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Probably transform.Rotate.

    https://docs.unity3d.com/ScriptReference/Transform.Rotate.html

    I'm confused by your "back to old position" statement. You probably don't need to modify the object's position. If you meant rotation, after you rotate a revolver's cylinder, doesn't it end up looking exactly as it did before the rotation since it would be symmetrical? So even if it immediately snapped back to the previous rotation, does that even matter because it would look exactly like that didn't happen, right?
     
  4. Trekko

    Trekko

    Joined:
    Jan 24, 2018
    Posts:
    21
    I'm not sure that I understand what you mean but:
    -when I shoot bullet #1 (on top) is destroyed and animation is played
    -barrel should rotate 60° to move new bullet on top
    -but in animation first frame rotation is setted so that empty bullet is on top and only solution I know is to make 6 animations of shooting