Forum Discussion
Ohyeahitsjosh
10 years agoHonored Guest
Rotation to teleport
Hey everyone,
I'm back again with another problem (seriously, I'm the LAST person on earth who should be programming). Essentially, I'm trying to teleport the player when they rotate on a teleportation pad (think Star Trek). However, I'm trying to get information from the first person camera and I can't quite get it to work.
Apparently
I'm back again with another problem (seriously, I'm the LAST person on earth who should be programming). Essentially, I'm trying to teleport the player when they rotate on a teleportation pad (think Star Trek). However, I'm trying to get information from the first person camera and I can't quite get it to work.
using UnityEngine;
using System.Collections;
using UnityEngine.VR;
public class RotateTeleporter : MonoBehaviour {
private bool playerInTeleporter;
private float playerInitialDirection;
Camera mycamera;
// Use this for initialization
void Start () {
playerInTeleporter = false;
playerInitialDirection = 0;
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter (Collider trig){
playerInitialDirection = GameObject.Find("FirstPersonCharacter").camera.transform.eulerAngles.x;
playerInTeleporter = true;
}
}
Apparently
playerInitialDirection = GameObject.Find("FirstPersonCharacter").camera.transform.eulerAngles.x; is outdated according to Unity. How should I write this? All I'm trying to do is teleport the player when they're on the pad and then rotate 180 degrees. Thanks!6 Replies
Replies have been turned off for this discussion
- cyberealityGrand ChampionWell, if you are trying to determine the yaw value (looking left or right) you want to be checking the y axis.
That code looks like it would compile. What is the actual error/warning that Unity is giving? - OhyeahitsjoshHonored Guest
"cybereality" wrote:
Well, if you are trying to determine the yaw value (looking left or right) you want to be checking the y axis.
That code looks like it would compile. What is the actual error/warning that Unity is giving?
It is giving me this back:
assets/Scripts/RotateTeleporter.cs(25,82): error CS0619: `UnityEngine.GameObject.camera' is obsolete: `Property camera has been deprecated. Use GetComponent<Camera>() instead. (UnityUpgradable)' - cyberealityGrand ChampionCan you try it like this:
GameObject.Find("FirstPersonCharacter").GetComponent<Camera>().transform.eulerAngles.x; - OhyeahitsjoshHonored GuestUnfortunately and ironically that brings back an error Unexpected symbol 'GetComponent'.
Removing get component gives the same error with: Unexpected symbol < - cyberealityGrand ChampionThat line of code seems to compile for me. What version of Unity are you using?
- timskHonored GuestHe's probably using UnityScript.
Try:playerInitialDirection = GameObject.Find("FirstPersonCharacter").GetComponent(Camera).transform.eulerAngles.x;
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 7 months ago