- Home /
How can I sit in chair and rotate the player 180 degrees towards the screen
Hello,
I need help with one thing. I want my character to sit in the chair in VR. So, when I go near a chair and the trigger is fired off, I want to be able to press X on the touch controller and sit in the chair. I have the button and trigger working, but I don't know how to lock my player position to the chair I'm facing. 
When I go sit in the chair, I want the player also to rotate 180 degrees towards the screen. Like he is in a cinema. So this is what I want. Press X and go sit in the chair and face the screen. 
This is my code so far. The first script is for the triggers on the chair and the second one is located on my xr rig.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ChairScript : MonoBehaviour
{
public void Start()
{
}
private void OnTriggerEnter(Collider collider)
{
if(collider.tag == "Player")
{
//Turn player 180 degree towards the screen
//Snap player to the chair so he can not move unless he press X again
}
}
private void OnTriggerExit(Collider collider)
{
if (collider.tag == "Player")
{
//Snap player to the chair so he can not move unless he press X again
}
}
}
public void OnSitOnChair(InputAction.CallbackContext context)
{
//Sit On Chair Action calling.
// IF Near empty chair && X pressed
if (chairScript)
{
//sit in chair? or what to call here?
}
I appreciate all kinds of help,
Greetings, Mariioo
Your answer
Follow this Question
Related Questions
Spawning an object with oculus controller 0 Answers
How to use the triggers on HTC Vive? 0 Answers
Eyes, Eyebrow and Eyeline issue with Vroid Model 0 Answers
Perception neuron + photon not working 0 Answers