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

Script to play video and teletransport?

Discussion in 'Scripting' started by JenMed, May 28, 2011.

  1. JenMed

    JenMed

    Joined:
    May 28, 2011
    Posts:
    5
    Hi, noob question here

    I have a project where the teacher wants an FPS where the player has to touch objects and when it does a videoclip must be triggered and when the clip is done the player should be in a different location within the world.

    I have seen various scripts for triggering videoclips and for teletransportation but I'm still left with a few doubts, How do I organize the code for the video to play and then for the player to appear in another location once the clip is done (in one gameobject)? Also, how do I define the new location to which the player is transported to?

    I'm completely new to this and learning this on my own to complete that project so all help is appreciated :)
     
  2. U7Games

    U7Games

    Joined:
    May 21, 2011
    Posts:
    943
    hi !..

    well, i don't have unitypro, and don't know how can this work.. but here we go:

    to activate a videoclip you must to add a box collider marked as trigger to the object you want to hit to and attach this following script, but before you must to create a plane in 3d view, make it fit to fullscreen in front of the camera... (if someone has a better solution for this put it :) )

    Code (csharp):
    1.  
    2. movieClip : MovieTexture;    //The avi, mpeg file.
    3. planeMovie : GameObject;   //Is the plane that will render the movie
    4.  
    5. function Start(){
    6. planeMovie.active = false;   //Disable temporally the plane
    7. }
    8.  
    9. function OnTriggerEnter(other : Collider){
    10. planeMovie.active = true;
    11. planeMovie.renderer.material.mainTexture = movieClip;
    12. movieClip.Play();
    13. }
    14.  
    one time you have done with the script, drag it and drop to the object where the fps must to collide.
    then drag the newly recently created plane to the inspector to planeMovie slot (gameObject).

    respecting to fps position, does your fps must to appear in a random location or a desired one point?...
     
    Last edited: May 28, 2011
  3. JenMed

    JenMed

    Joined:
    May 28, 2011
    Posts:
    5


    To a desired point please!!

    When I create the plane I just put in in front of the camara and it'll only appear when the videoclip is activated? Isnt there a way for the scene to change to a videoclip that will take up the whole screen? Thanks for the script! But i really do need to know how to transport the player into a specific location T.T