Search Unity

Making a character in a boat row left or right depending on direction of navmesh agent?

Discussion in 'Animation' started by frogwise, May 22, 2018.

  1. frogwise

    frogwise

    Joined:
    Nov 27, 2009
    Posts:
    103
    I have a little character in a rowboat. The game is a simple click-to-move game using a NavMesh agent for the boat.

    If I make 3 animations:

    1. 1. row left
    2. 2. row right
    3. 3. row both

    Could I set it up so that when the boat is rotating right, the row left animation is playing, when rotating left, the row right animation is playing, and when moving forward, the row both animation is playing?

    Thanks in advance!
     
  2. peaceamit

    peaceamit

    Joined:
    Jul 18, 2015
    Posts:
    9
    Not sure if this is still relevent to you. However you can do Vector3.Dot() of NavMeshAgent ForwardVector and NavemeshmovementDelta Vector. This will show whether NavemeshmovementDelta vector is towards Right, Approx Mid Or Left of NavMeshAgent. You can then change the animation accordingly. Calculate result per frame and smooth out the Dot product result over frame to reduce jitter.