How to create a book that can be called anywhere and interacted with. Like a journal.
Hello,
I have been all over the internet for the past 3 days trying to find a solution to my dilemma, but to no avail. So I come to here with my question.
Is there a way I can create a 3D book and call it when pressing a key (say "b") and flip through the pages, without creating a canvas (2D) version of it.
My goal is to make like a 3D version of this: Myst Library
Or more accurately this: Revelation Journal
I've uploaded screencasts of my current workings of it all:
My book without any follow script or anything
My book with the script posted below attached to it
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class paperLookBook : MonoBehaviour
{
public bool visible = true;
public GameObject guide;
public Vector3 offsetRot = new Vector3(-8f, 90f, 95f);
public GameObject player;
void Start()
{
transform.parent = null;
guide = GameObject.FindGameObjectWithTag("centerGuidePaper");
player = GameObject.FindGameObjectWithTag("Player");
}
void Update(){
if(Input.GetKeyDown("b")){
toggleVisible();
}
followPlayer();
}
public void toggleVisible(){
visible = !visible;
disablePlayer();
}
public void disablePlayer(){
Debug.Log("disable player");
player.GetComponentInChildren<camMouseLook>().enabled = visible;
player.GetComponent<playerMovement>().enabled = visible;
player.GetComponent<Rigidbody>().isKinematic = visible;
}
void followPlayer(){
transform.position = guide.transform.position;
transform.eulerAngles = guide.transform.eulerAngles + offsetRot;
transform.parent = guide.transform;
}
}
Essentially in order for it to follow the player, there is a child already on the player called centerGuide. The code for it is as follows:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class centerGuide : MonoBehaviour
{
public Camera cam;
public float distance = 3f;
void Start()
{
cam = Camera.main;
}
void LateUpdate()
{
locationView();
rotateView();
}
void rotateView(){
transform.LookAt(transform.position + cam.transform.rotation * Vector3.forward,
cam.transform.rotation * Vector3.up);
Vector3 currRot = transform.eulerAngles;
Vector3 rot = new Vector3(currRot.x + 180f, currRot.y, currRot.z + 180f);
transform.eulerAngles = rot;
}
void locationView(){
Vector3 setPos = cam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, distance));
transform.position = setPos;
}
}
At this point I have no clue what to do. I'm not sure whether I should scrap this idea and try and figure something else out or if I'm going about it a really stupid way.
Any and all help would be much appreciated!
P.S. I should mention that I am a beginner at this. I've come a good way from not knowing anything, but I still don't know some super advanced things. If you find a solution that involves something advanced, could you explain it or provide documentation or something. Thanks!
Your answer
Follow this Question
Related Questions
How to slide in a fps game 1 Answer
How to implement the ability to move and place objects in HoloLens Application? 0 Answers
Unity Gameobjects aren't showing up in the hierarchy but can see them in gameview 0 Answers
I get errors that say GameCoreXbox after installing Cinemachine 0 Answers
3D FPS Aiming with Touch Controls 1 Answer