Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

need help w/ video player script

Discussion in 'Scripting' started by avenn503, Dec 8, 2018.

  1. avenn503

    avenn503

    Joined:
    Dec 8, 2018
    Posts:
    1
    i want to create a script that plays video clip when i collide with an object, here is what i have:
    Code (JavaScript):
    1. public class PlayVideo : MonoBehaviour
    2. {
    3.     public GameObject videoPlayer;
    4.     public int timeToStop;
    5.  
    6.     void Start()
    7.     {
    8.         videoPlayer.SetActive(false);
    9.     }
    10.  
    11.     void OnTriggerEnter(Collider player)
    12.     {
    13.         if (player.gameObject.tag == "Player")
    14.         {
    15.             videoPlayer.SetActive(true);
    16.             Destroy(videoPlayer, timeToStop);
    17.         }
    18.     }
    19. }
    it doesnt seem to work and i couldnt figure it out what is wrong. any help?
    @LurkingNinjaDev i want to destroy the video clip after it finish playing so it doesnt stay on the screen for the entire time.
     
    Last edited: Dec 8, 2018
  2. Put your code in code tags in your post please. Hit Edit link on the bottom of your post, you can find the code button in the toolbar while you're editing it.

    As for your problem: Why are you destroying your videoPlayer object? What is the value of the timeToStop?