Hey! So I am trying to recreate the classic tamagotchi game on unity. I have created a 3d model of the tamagotchi device and I want the game to play on the screen of the device.
My plan was to have the video player attached to the a box object that acts as a game screen. I have little buttons on the device made out of cylinders. I have created a video of the initial egg hatching animation and I want it to play when the middle button is pressed as a way of starting the game. I have put a collider on this button.
I have literally NO UNITY OR CODING experience. This is for a class I am taking and the professor is not the best at explaining things and we did not look at these specific codes in class.
I put a collider on the cylinder object so I can ray cast on it and potentially put a onmousedown command thing so that when the object is clicked an event can occur. The event I want to happen is a video playing within a box like a tv screen.
This is what I have so far and of course it doesnt even run. But i do think some of what I have is on the right track.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class startbutton : MonoBehaviour
{
public GameObject startbutton;
public UnityEvent OnMouseDown= new UnityEvent();
// Start is called before the first frame update
void Start()
{
startbutton = Cyllinder002.gameObject;
GameObject box1 = GameObject.Find("Box001");
var videoPlayer = box1.AddComponent<UnityEngine.Video.VideoPlayer>();
videoPlayer.playOnAwake = false;
videoPlayer.url = "/Users/jponcel/Desktop/unity/New Unity Project/Assets/tamahatchvid.mp4";
videoPlayer.isLooping = false;
}
// Update is called once per frame
void Update()
{
var Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit Hit;
if (Input.GetMouseButtonDown(0))
{
if (Physics.Raycast(Ray, out Hit) && Hit.collider.gameobject == gameObject)
{
Debug.Log("Buttton Clicked")
void OnMouseDown() {
public VideoPlayer videoPlayer;
public void playVideo();
videoPlayer = GetComponent<VideoPlayer>();
videoPlayer.Play();
}
}
}
}
}
lmk if u have any ideas of how i can execute this properly i am close 2 sobbing
thank u sm