Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Teleport to position

Discussion in 'Community Learning & Teaching' started by lw_wh, Oct 5, 2022.

  1. lw_wh

    lw_wh

    Joined:
    Nov 1, 2021
    Posts:
    21
    Hello,
    Goodday!
    I have a simple question i think, because i m a beginner.
    I have in a Room a table with CityOnTable object (in this object there are more objects like buildings, road, etc) on the table. I also have CityReal thats is the same as CityOnTable but is scaled x 1000.
    upload_2022-10-5_16-11-54.png
    upload_2022-10-5_16-18-23.png

    Now i want to use my Quest 2 controller to focus and click (teleport) on the CityOnTable with the result that i teleport to that coordinate(location) in CityReal.

    I tried something like this, but its long not good enough.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class Teleport : MonoBehaviour
    6. {
    7.  
    8.     public void OnTriggerEnter(Collider other)
    9.     {
    10.         other.transform.position = transform.position.x *1000,transform.position.y *1000;
    11.  
    12.  
    13.     }
    14. }
    And enabled a trigger on the CityOnTable object and place the above script in this object.
    upload_2022-10-5_16-22-23.png

    Can someone help me with this?
    best regards