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

Question Rotation independently

Discussion in 'Scripting' started by TheSilverHand, Nov 15, 2021.

  1. TheSilverHand

    TheSilverHand

    Joined:
    Jan 29, 2021
    Posts:
    16
    İ want rotate my character upper body independently from lower body.Upper body will follow mouse position.By the way its top down shooter on 3D template.İ tried almost everything but I couldnt solve it.any idea ?
     
  2. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    1,315
    What have you tried?
     
    Shreddedcoconut likes this.
  3. TheSilverHand

    TheSilverHand

    Joined:
    Jan 29, 2021
    Posts:
    16
    Literally what you can find in google.So i already checked tutorials it didnt work for me.Last thing what I have tried, I tracked mouse position on world position with ray cast.Then I used it for change upper body localeulerangles.It worked but problem is when character move opposite direction body follow to mouse with inverse position. When I want turn it right it turn it left or left to right
     
  4. Shreddedcoconut

    Shreddedcoconut

    Joined:
    Jul 30, 2021
    Posts:
    61
    So your character's upper body is facing backwards from where it's supposed to be facing when it isn't supposed to?
     
  5. TheSilverHand

    TheSilverHand

    Joined:
    Jan 29, 2021
    Posts:
    16
    No, I clamp the values it works correctly.Problem is my character's controller is looks like witcher what button you press it facing that direction with all body.So for example if I press W and rotate upper body with mouse it works correctly but if I press S upper body doesnt rotate correctly when I move to mouse left upper body looks right or when mouse on right it looks left.Same with A and D direction aswell
     
    Shreddedcoconut likes this.
  6. TheSilverHand

    TheSilverHand

    Joined:
    Jan 29, 2021
    Posts:
    16
    I found solution.I just used some object as target reference instead of mouse position.But now character animations have weird behaviour.
     
    Last edited: Nov 16, 2021
    Shreddedcoconut likes this.
  7. Shreddedcoconut

    Shreddedcoconut

    Joined:
    Jul 30, 2021
    Posts:
    61
    Upper body and lower body should have their own respective animations, so that they don't cause strange behavior.
     
    TheSilverHand likes this.
  8. TheSilverHand

    TheSilverHand

    Joined:
    Jan 29, 2021
    Posts:
    16
    Yes !,I used avatar masks for both lower body and upper body now all animations work as it should. Thanks a lot for idea :)
     
    Shreddedcoconut likes this.
  9. razzraziel

    razzraziel

    Joined:
    Sep 13, 2018
    Posts:
    362
    Also you can use ik pass to rotate spline bone with unity ik to your desired target. When it is too much, character can start to rotate too.
     
  10. TheSilverHand

    TheSilverHand

    Joined:
    Jan 29, 2021
    Posts:
    16
    I will check this as well thank you.