Search Unity

Problems with ETeeski Tutorial 1.8 Basic Gun with Weight

Discussion in 'Scripting' started by Vordas32, Sep 9, 2012.

  1. Vordas32

    Vordas32

    Joined:
    Sep 9, 2012
    Posts:
    15
    Problem with 1.8 Basic Gun with Weight

    On my Gunscript everything works great but a gun do not have good smooth, its jitter. I tried to put the whole code in LateUpdate() and just targetXRotation, targetYRotation in LateUpdate() but gun still has the jitter. When I put targetXRotation, targetYRotation in LateUpdate() a gun have smaller jitter but it still have. Can anyone help on this problem? Master how to solve this? Is it up to my pc that is slow. Maybe is framerates? Please help the teacher. :) Btw. Your videos is great. I like that you go in so details.

    Code:

    Code (csharp):
    1. var cameraObject:GameObject;
    2. @HideInInspector
    3. var targetXRotation:float;
    4. @HideInInspector
    5. var targetYRotation:float;
    6. @HideInInspector
    7. var targetXRotationV:float;
    8. @HideInInspector
    9. var targetYRotationV:float;
    10. var speedOfRotationSmooth:float = 0.5;
    11. var gunHoldSide:float = 0.5;
    12. var gunHeightSide:float = -0.5;
    13. var gunForwardSide:float = 0.5;
    14.  
    15. function Update ()
    16. {
    17.     transform.position = cameraObject.transform.position + (Quaternion.Euler(0, targetYRotation, 0) * Vector3(gunHoldSide, gunHeightSide, gunForwardSide));
    18.    
    19.     /*targetXRotation = Mathf.SmoothDamp(targetXRotation, cameraObject.GetComponent(MouseLook).XRotation, targetXRotationV, speedOfRotationSmooth);
    20.     targetYRotation = Mathf.SmoothDamp(targetYRotation, cameraObject.GetComponent(MouseLook).YRotation, targetYRotationV, speedOfRotationSmooth);*/
    21.    
    22.     transform.rotation = Quaternion.Euler(targetXRotation, targetYRotation, 0);
    23.     //transform.rotation *= Time.deltaTime;
    24. }
    25.  
    26. function LateUpdate()
    27. {  
    28.     targetXRotation = Mathf.SmoothDamp(targetXRotation, cameraObject.GetComponent(MouseLook).XRotation, targetXRotationV, speedOfRotationSmooth);
    29.     targetYRotation = Mathf.SmoothDamp(targetYRotation, cameraObject.GetComponent(MouseLook).YRotation, targetYRotationV, speedOfRotationSmooth);
    30. }
     
  2. rockky36

    rockky36

    Joined:
    Nov 21, 2013
    Posts:
    1
    I am facing the same problem , cant find any sollution , if u have solved it ..plz let me know .thanks