Search Unity

Set players look direction

Discussion in 'FPS.Sample Game' started by m0uka, Jun 6, 2019.

  1. m0uka

    m0uka

    Joined:
    Jul 9, 2017
    Posts:
    4
    Hey, I have been trying to create a recoil system but I am not sure how to set the players look direction..
    Could anyone help me with that?
    I tried editing CharacterInterpolatedData's aimYaw and aimPitch, but nothing seemed to happen.

    Thanks
     
  2. karstenv

    karstenv

    Joined:
    Jan 12, 2014
    Posts:
    81
    We tried this and it didn't work out too well as it seem that the server didn't always approve of the recoil in time. This lead to the recoil actually happen before a shot was fired.

    So it worked like 85% of the time.
    We never found a solution and moved on and removed it from the game (for now).
     
  3. m0uka

    m0uka

    Joined:
    Jul 9, 2017
    Posts:
    4
    Alright, guess I'll have to use only aim spread, but thanks for the help
     
  4. karstenv

    karstenv

    Joined:
    Jan 12, 2014
    Posts:
    81
    It could probably be done by delaying the recoil a server tick to make sure it actually fired the weapon first.

    But again, we moved on so I have other task on my plate before I can look into that again.
     
  5. m0uka

    m0uka

    Joined:
    Jul 9, 2017
    Posts:
    4
    Sure, please let me know when you solve it
     
  6. nanoblubb

    nanoblubb

    Joined:
    Oct 29, 2016
    Posts:
    9
    You could try to calculate the recoil only on the server and predicting it to the client. I implemented in a diffrent project something simelear, where a had for evry weapon recoil patterns. So i made a GUI Editor script where you can draw the recoil pattern and the script translates each point of this pattern to a x/y offset of the weapon. the server and client than calculating the recoil position depended on the shoots fired till recoil reset.
     
    Journeythedev likes this.
  7. Dan24

    Dan24

    Joined:
    Jan 4, 2017
    Posts:
    3
    I am not understanding this question, Why are you trying to network recoil? Someone said "recoil happen before a shot is fired" This sounds very wrong. recoil should be client predicted along with the shot(s). So in other words, let the player shoot, and apply recoil on the client. On the server simulate recoil, and check shots. If a hacker wants to mess with recoil client-side, let them as it wont have an effect on whats really happening on the server on a server authoritative model. This works really well if you have a set recoil pattern, which if you have a competitive shooter at all, you need. If your recoil pattern is random that is much harder problem.