I want that when my character enter into a room a video automatically play and when he leaves the room the video "turns off".
I made a room in Autodesk 3ds Max and I exported to Unity, and now I want to make that a television that is inside the room automatically play a video when the character enters in the room and the video "turns off" when the character leaves the room. To test I put a Box Collider and a RigidBody in the camera and a Box Collider attached to a GameObject that has the exact size of the room and I put the GameObject inside the room. But I still need to create a C # Script and attach the Script to the camera to make the project work. The problem is that I'm still very new to programming languages, please help me to make my project work.
Answer by highpockets · May 29, 2019 at 02:05 PM
The way you have it with a boxcollider the size of the room works and you can mark it as a trigger in the inspector. Now you say the other collider is on the camera, I'm guessing this is a first person perspective game and the camera is your player. The box collider in the room needs to have a script on it and you need to use the function "void OnTriggerEnter(Collider other)". And you can give your player/camera a Tag, which if it is the MainCamera, it usually already is tagged as such, but you can also make the tag anything you want. If you select your object and scroll to the top of the inspector, the tag dropdown is right above the transform component. Choose a tag. Lets say your tag is "Player", now you have to check to see if the "other" collider has the tag inside that OnTriggerEnter() function and if it is the tag you expect, you play the video or turn it off during OnTriggerExit(). I'm not going to tell you more than that, as unity answers isn't for asking for someone to give you a script. But if you check out some tutorials and the Scripting API and come back here with an attempt to make this happen, then I or someone else will surely help you work it out