Search Unity

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

Question Animation not working on Oculus Quest

Discussion in 'VR' started by gustavfrisk, Nov 12, 2020.

  1. gustavfrisk

    gustavfrisk

    Joined:
    May 12, 2020
    Posts:
    3
    In unity everything works fine. My character walks up to a point and then I use animationComponent.Play to change the animation but when I build and run on the Oculus Quest, the character just keeps on walking. It doesn't change the animation like it does inside Unity. Can anybody help?
     
    ChiragSindhu2002 likes this.
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    There's nothing Quest-specific when it comes to animation. You'll need to provide a lot more detail than that to get any help, I think.
     
  3. gustavfrisk

    gustavfrisk

    Joined:
    May 12, 2020
    Posts:
    3
    That's why it's so weird. When I run it in unity everything works fine and then I build it and run it on the Quest and the animation change just doesn't happen. Apart from that everything acts as supposed to. I'm sorry if I don't have any more detail, I can't even guess what could be the issue, I'm fairly new to unity and oculus development.

    However, could it be something like that the script handling the animation change doesn't convert or gets included in the build or something like that? Because one thing I noticed is that when I have visual studio open and try to hit play, unity crashes. But when I close visual studio and hit play it works. That didn't happen when I didn't have the OVRCameraRig. Could that mean that the script is corrupt in some way?

    Here is the script. I don't know if it helps with detail, but anyway.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class ChangeAnimation : MonoBehaviour
    6. {
    7.     public WaypointMover waypointMover;
    8.     public AnimationClip newAnimation;
    9.     Animation animationComponent;
    10.     private Vector3 charPos;
    11.     private Vector3 pointPos;
    12.     private Vector3 pointPos2;
    13.  
    14.  
    15.     void Start()
    16.     {
    17.         if (!waypointMover)
    18.         {
    19.             waypointMover = GetComponent<WaypointMover>();
    20.             animationComponent = GetComponent<Animation>();
    21.         }
    22.         pointPos = GameObject.Find("_waypoint (2)").transform.position;
    23.     }
    24.  
    25.     private void Update()
    26.     {
    27.         charPos = GameObject.Find("woman_1046").transform.position;
    28.         pointPos = GameObject.Find("_waypoint (2)").transform.position;
    29.         pointPos2 = GameObject.Find("_waypoint (6)").transform.position;
    30.  
    31.         if (Vector3.Distance(charPos, pointPos) >= 1 && (Vector3.Distance(charPos, pointPos2) >= 1))
    32.         {
    33.             animationComponent.Play("walk");
    34.         }
    35.     }
    36.  
    37.  
    38.     void ChangeAnim ()
    39.     {
    40.         charPos = GameObject.Find("woman_1046").transform.position;
    41.         pointPos = GameObject.Find("_waypoint (2)").transform.position;
    42.         pointPos2 = GameObject.Find("_waypoint (6)").transform.position;
    43.  
    44.         if (Vector3.Distance(charPos, pointPos) <= 1)
    45.         {
    46.             animationComponent.PlayQueued("Looking_around", QueueMode.PlayNow);
    47.             animationComponent.PlayQueued("Use_object", QueueMode.CompleteOthers);
    48.         }
    49.  
    50.         if (Vector3.Distance(charPos, pointPos2) <= 1)
    51.         {
    52.             animationComponent.PlayQueued("Looking_around", QueueMode.PlayNow);
    53.             animationComponent.PlayQueued("Use_object", QueueMode.CompleteOthers);
    54.         }
    55.     }
    56. }
    57.  
     
  4. Danielsantalla

    Danielsantalla

    Joined:
    Jan 7, 2015
    Posts:
    75
    Did you find a solution to this? The same is happening to me, animation doesn't work on build
     
  5. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,022
    Make a new post instead of reviving an old one.
    And make sure everything is updated before making one
     
  6. Deleted User

    Deleted User

    Guest

    there is no conditional logic that calls ChangeAnim()...anywhere in the update/fixed update method.
    Try moving any conditional logic to the update method, and call your change function in the game loop.

    This is a code error and that 'animation function' will never be called, even in the editor, until you call it.
    ie..
    Code (CSharp):
    1.  
    2.     private void Update()
    3.     {
    4.         charPos = GameObject.Find("woman_1046").transform.position;
    5.         pointPos = GameObject.Find("_waypoint (2)").transform.position;
    6.         pointPos2 = GameObject.Find("_waypoint (6)").transform.position;
    7.         if (Vector3.Distance(charPos, pointPos) >= 1 && (Vector3.Distance(charPos, pointPos2) >= 1))
    8.         {
    9.             animationComponent.Play("walk");
    10.         }
    11. // HERE - CALL THE ACTUAL Function, and pass the values ONCE..see you are already looking the same values up in update!!
    12.         else
    13.     {
    14.         ChangeAnim(charPos,pointPos,pointPos2);
    15.      }
    16. void ChangeAnim (Vector3 charPos,Vector3 pointPos, Vector3 pointPos2)
    17.   {
    18.         if (Vector3.Distance(charPos, pointPos) <= 1)
    19.         {
    20.             animationComponent.PlayQueued("Looking_around", QueueMode.PlayNow);
    21.             animationComponent.PlayQueued("Use_object", QueueMode.CompleteOthers);
    22.         }
    23.         if (Vector3.Distance(charPos, pointPos2) <= 1)
    24.         {
    25.             animationComponent.PlayQueued("Looking_around", QueueMode.PlayNow);
    26.             animationComponent.PlayQueued("Use_object", QueueMode.CompleteOthers);
    27.         }
    28.   }
    29.  
     
    Last edited by a moderator: May 7, 2022