public class RayCast : MonoBehaviour
{
public float distanceToSee;
RaycastHit whatIHit;
JournalText journaltext;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
Debug.DrawRay(this.transform.position, this.transform.forward * distanceToSee, Color.magenta);
if (Physics.Raycast(this.transform.position, this.transform.forward, out whatIHit, distanceToSee))
{
if(Input.GetKeyDown(KeyCode.E))
{
//Debug.Log("I Touched " + whatIHit.collider.gameObject.name);
if(whatIHit.collider.tag == "Journal")
{
//Debug.Log("tag: " + whatIHit.collider.tag);
if(whatIHit.collider.gameObject.GetComponent<Interact>().whatBookAmI == Interact.Interacter.journal)
{
//Debug.Log("I Touched " + whatIHit.collider.gameObject.name + "tag: " + whatIHit.collider.tag);
//Destroy(whatIHit.collider.gameObject);
JournalText journalText = GetComponent<JournalText>();
whatIHit.collider.gameObject.GetComponent<JournalText>().JournalPress();
}
}
}
}
}
}
using UnityEngine;
using System.Collections;
[System.Serializable]
public class JournalPage
{
public Canvas journalPages;
}
public class JournalText : MonoBehaviour
{
public JournalPage journalPage;
void Start()
{
journalPage.journalPages = journalPage.journalPages.GetComponent<Canvas>();
journalPage.journalPages.enabled = false;
}
public void JournalPress()
{
journalPage.journalPages.enabled = true;
}
}
I’m trying to get a image to appear when the person using the Oculus rift hits E on a book. Only problem i’m having is the image showing up.