Skip to main content
formatting
Source Link
Vaillancourt
  • 16.4k
  • 17
  • 56
  • 61
    public class animationSync1 : MonoBehaviour
{

    // Animation component 
    private Animation animator;

    // Video player (add via inspector)
    public VideoPlayer vp; 

    // total frame count of video 
    private float totalFrame; 

    // current video frame
    private float currentFrame;

    // animation frame count
    private float animationFrame;

    // Start is called before the first frame update
    void Start()
    {

        // Animation component
        animator = GetComponent<Animation>();

        // get total number of frames from video file
        totalFrame = vp.frameCount;

        // start video playback
        vp.Play();

        // begin playback of animation
        animator.Play("Camera_entrance|Camera_entranceAction");
        // set animation speed to 0 in order to set the animation frame point manually in fixed update
        animator["Camera_entrance|Camera_entranceAction"].speed = 0f;
        
    }

    // Use of fixed update to call 30 times a second (to try to match up to video and animation playback)
    void FixedUpdate()
    {

        // get current video frame
        currentFrame = vp.frame;

        // get frame count between 0 - 1 from current video frame 
        animationFrame = currentFrame / totalFrame; 

        // set the animation position to that of the current video frame
        animator["Camera_entrance|Camera_entranceAction"].normalizedTime = animationFrame;
        
    }
}
    public class animationSync1 : MonoBehaviour
{

    // Animation component 
    private Animation animator;

    // Video player (add via inspector)
    public VideoPlayer vp; 

    // total frame count of video 
    private float totalFrame; 

    // current video frame
    private float currentFrame;

    // animation frame count
    private float animationFrame;

    // Start is called before the first frame update
    void Start()
    {

        // Animation component
        animator = GetComponent<Animation>();

        // get total number of frames from video file
        totalFrame = vp.frameCount;

        // start video playback
        vp.Play();

        // begin playback of animation
        animator.Play("Camera_entrance|Camera_entranceAction");
        // set animation speed to 0 in order to set the animation frame point manually in fixed update
        animator["Camera_entrance|Camera_entranceAction"].speed = 0f;
        
    }

    // Use of fixed update to call 30 times a second (to try to match up to video and animation playback)
    void FixedUpdate()
    {

        // get current video frame
        currentFrame = vp.frame;

        // get frame count between 0 - 1 from current video frame 
        animationFrame = currentFrame / totalFrame; 

        // set the animation position to that of the current video frame
        animator["Camera_entrance|Camera_entranceAction"].normalizedTime = animationFrame;
        
    }
}
public class animationSync1 : MonoBehaviour
{

    // Animation component 
    private Animation animator;

    // Video player (add via inspector)
    public VideoPlayer vp; 

    // total frame count of video 
    private float totalFrame; 

    // current video frame
    private float currentFrame;

    // animation frame count
    private float animationFrame;

    // Start is called before the first frame update
    void Start()
    {

        // Animation component
        animator = GetComponent<Animation>();

        // get total number of frames from video file
        totalFrame = vp.frameCount;

        // start video playback
        vp.Play();

        // begin playback of animation
        animator.Play("Camera_entrance|Camera_entranceAction");
        // set animation speed to 0 in order to set the animation frame point manually in fixed update
        animator["Camera_entrance|Camera_entranceAction"].speed = 0f;
        
    }

    // Use of fixed update to call 30 times a second (to try to match up to video and animation playback)
    void FixedUpdate()
    {

        // get current video frame
        currentFrame = vp.frame;

        // get frame count between 0 - 1 from current video frame 
        animationFrame = currentFrame / totalFrame; 

        // set the animation position to that of the current video frame
        animator["Camera_entrance|Camera_entranceAction"].normalizedTime = animationFrame;
        
    }
}
    public class animationSync1 : MonoBehaviour

{

{

    // Animation component 
    private Animation animator;

    // Video player (add via inspector)
    public VideoPlayer vp; 

    // total frame count of video 
    private float totalFrame; 

    // current video frame
    private float currentFrame;

    // animation frame count
    private float animationFrame;

    // Start is called before the first frame update
    void Start()
    {

        // Animation component
        animator = GetComponent<Animation>();

        // get total number of frames from video file
        totalFrame = vp.frameCount;

        // start video playback
        vp.Play();

        // begin playback of animation
        animator.Play("Camera_entrance|Camera_entranceAction");
        // set animation speed to 0 in order to set the animation frame point manually in fixed update
        animator["Camera_entrance|Camera_entranceAction"].speed = 0f;
        
    }

    // Use of fixed update to call 30 times a second (to try to match up to video and animation playback)
    void FixedUpdate()
    {

        // get current video frame
        currentFrame = vp.frame;

        // get frame count between 0 - 1 from current video frame 
        animationFrame = currentFrame / totalFrame; 

        // set the animation position to that of the current video frame
        animator["Camera_entrance|Camera_entranceAction"].normalizedTime = animationFrame;
        
    }
}

}

public class animationSync1 : MonoBehaviour

{

// Animation component 
private Animation animator;

// Video player (add via inspector)
public VideoPlayer vp; 

// total frame count of video 
private float totalFrame; 

// current video frame
private float currentFrame;

// animation frame count
private float animationFrame;

// Start is called before the first frame update
void Start()
{

    // Animation component
    animator = GetComponent<Animation>();

    // get total number of frames from video file
    totalFrame = vp.frameCount;

    // start video playback
    vp.Play();

    // begin playback of animation
    animator.Play("Camera_entrance|Camera_entranceAction");
    // set animation speed to 0 in order to set the animation frame point manually in fixed update
    animator["Camera_entrance|Camera_entranceAction"].speed = 0f;
    
}

// Use of fixed update to call 30 times a second (to try to match up to video and animation playback)
void FixedUpdate()
{

    // get current video frame
    currentFrame = vp.frame;

    // get frame count between 0 - 1 from current video frame 
    animationFrame = currentFrame / totalFrame; 

    // set the animation position to that of the current video frame
    animator["Camera_entrance|Camera_entranceAction"].normalizedTime = animationFrame;
    
}

}

    public class animationSync1 : MonoBehaviour
{

    // Animation component 
    private Animation animator;

    // Video player (add via inspector)
    public VideoPlayer vp; 

    // total frame count of video 
    private float totalFrame; 

    // current video frame
    private float currentFrame;

    // animation frame count
    private float animationFrame;

    // Start is called before the first frame update
    void Start()
    {

        // Animation component
        animator = GetComponent<Animation>();

        // get total number of frames from video file
        totalFrame = vp.frameCount;

        // start video playback
        vp.Play();

        // begin playback of animation
        animator.Play("Camera_entrance|Camera_entranceAction");
        // set animation speed to 0 in order to set the animation frame point manually in fixed update
        animator["Camera_entrance|Camera_entranceAction"].speed = 0f;
        
    }

    // Use of fixed update to call 30 times a second (to try to match up to video and animation playback)
    void FixedUpdate()
    {

        // get current video frame
        currentFrame = vp.frame;

        // get frame count between 0 - 1 from current video frame 
        animationFrame = currentFrame / totalFrame; 

        // set the animation position to that of the current video frame
        animator["Camera_entrance|Camera_entranceAction"].normalizedTime = animationFrame;
        
    }
}
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
added 1554 characters in body
Source Link
Nic
  • 1
  • 2

Thanks.I've included my code below :

public class animationSync1 : MonoBehaviour

{

// Animation component 
private Animation animator;

// Video player (add via inspector)
public VideoPlayer vp; 

// total frame count of video 
private float totalFrame; 

// current video frame
private float currentFrame;

// animation frame count
private float animationFrame;

// Start is called before the first frame update
void Start()
{

    // Animation component
    animator = GetComponent<Animation>();

    // get total number of frames from video file
    totalFrame = vp.frameCount;

    // start video playback
    vp.Play();

    // begin playback of animation
    animator.Play("Camera_entrance|Camera_entranceAction");
    // set animation speed to 0 in order to set the animation frame point manually in fixed update
    animator["Camera_entrance|Camera_entranceAction"].speed = 0f;
    
}

// Use of fixed update to call 30 times a second (to try to match up to video and animation playback)
void FixedUpdate()
{

    // get current video frame
    currentFrame = vp.frame;

    // get frame count between 0 - 1 from current video frame 
    animationFrame = currentFrame / totalFrame; 

    // set the animation position to that of the current video frame
    animator["Camera_entrance|Camera_entranceAction"].normalizedTime = animationFrame;
    
}

}

Thanks.

I've included my code below :

public class animationSync1 : MonoBehaviour

{

// Animation component 
private Animation animator;

// Video player (add via inspector)
public VideoPlayer vp; 

// total frame count of video 
private float totalFrame; 

// current video frame
private float currentFrame;

// animation frame count
private float animationFrame;

// Start is called before the first frame update
void Start()
{

    // Animation component
    animator = GetComponent<Animation>();

    // get total number of frames from video file
    totalFrame = vp.frameCount;

    // start video playback
    vp.Play();

    // begin playback of animation
    animator.Play("Camera_entrance|Camera_entranceAction");
    // set animation speed to 0 in order to set the animation frame point manually in fixed update
    animator["Camera_entrance|Camera_entranceAction"].speed = 0f;
    
}

// Use of fixed update to call 30 times a second (to try to match up to video and animation playback)
void FixedUpdate()
{

    // get current video frame
    currentFrame = vp.frame;

    // get frame count between 0 - 1 from current video frame 
    animationFrame = currentFrame / totalFrame; 

    // set the animation position to that of the current video frame
    animator["Camera_entrance|Camera_entranceAction"].normalizedTime = animationFrame;
    
}

}

added 960 characters in body
Source Link
Nic
  • 1
  • 2
Loading
Source Link
Nic
  • 1
  • 2
Loading