Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Resolved Fps character vertical mouse aim

Discussion in 'Getting Started' started by SamAdamsUK, Aug 26, 2023.

  1. SamAdamsUK

    SamAdamsUK

    Joined:
    Mar 21, 2023
    Posts:
    8
    Hi All,

    I need some advice if possible. I'm making an FPS game. The player character rotates left and right fine via mouse look, the hands/weapon are set up via rigging fine.
    The issue I'm having is that I'm not sure of the best way to use mouse look to rotate the characters upper body to follow the aim direction. I can setup a multi aim comstraint, and moving the aim target manually in the scene view does make the character look at it dynamically. The bit I'm missing though is how to affect this target using script so it rotates with mouse look up and down. If I create a child object sat within the player and rotate this, with the aim object as a child of this, I would expect it to work but the aim constraint doesn't follow it. It seems like the aim constraint won't work if it's a local/child object.
    Hoping there's a standard method to use to do this - it's going to be multiplayer so I need the character to be visibly leaning back and and forth to other players. Purely rotating the spine via mouse without using rigging doesn't work as it's not transmitted across multiplayer. Sorry for the brain dump! Really need some pointers as my passion for this game will start to take a dive.
    Thanks! :)
     
  2. SamAdamsUK

    SamAdamsUK

    Joined:
    Mar 21, 2023
    Posts:
    8
    So in the end I added an additional game object at the same position as the spine pivot, rotating that via script, and a rig with a rotation constraint that rotates the spine using this objects rotation. A bit of a hack but it seems to work well and I'm assuming the network animator in netcode/fishnet will display these. Not something that's covered in any tutorials I've seen as they're all 3rd person so there's no risk of infinite positi8ning loops with the camera attached to the rotation that's happening.Feel free to close admin.
     
    ijmmai likes this.
  3. ijmmai

    ijmmai

    Joined:
    Jun 9, 2023
    Posts:
    188
    Good to hear you solved it.
    You can mark the post Resolved, yourself. There are Thread tools at the top, edit the title tag
     
    SamAdamsUK likes this.