Search Unity

Question Lego Microgame's Teleport

Discussion in 'Editor & General Support' started by superUFO, Dec 20, 2020.

  1. superUFO

    superUFO

    Joined:
    Dec 20, 2020
    Posts:
    25
    Hello,
    I want to add a teleport in my Lego Microgame project, but I have no any Teleportation(?) Behaviour Brick :-( if you have a link how to do the Lego teleport then please let me know!
    Dear Unity creators, please add the Teleport Behavior Brick in new version of Unity Lego Microgame!
    I need teleport. Please help me.
    teleport.jpg
     
    Last edited: Dec 20, 2020
  2. superUFO

    superUFO

    Joined:
    Dec 20, 2020
    Posts:
    25
    how activate my teleport script? In Touch Trigger? Player Minifig dont move. Help! teleport2.jpg

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class followTV : MonoBehaviour
    {
    public GameObject player;
    public GameObject player2;

    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
    player2.transform.position = player.transform.position;

    }
    }
     
    Last edited: Dec 22, 2020
  3. superUFO

    superUFO

    Joined:
    Dec 20, 2020
    Posts:
    25
    WOW! I know how do it!
    player - the item you're teleporting to
    player2 - Minifig
    offset - the distance between Minifig and the object you're teleporting to
    T - button activate the teleporter


    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class followTV : MonoBehaviour
    {
    public GameObject player;
    public GameObject player2;
    private Vector3 offset = new Vector3(10, 0, 25);

    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
    if (Input.GetKeyDown(KeyCode.T))
    {
    player2.transform.position = player.transform.position + offset;
    }

    }
    }
     
    Last edited: Dec 22, 2020
  4. superUFO

    superUFO

    Joined:
    Dec 20, 2020
    Posts:
    25
    The final version of the LEGO Minifig teleport!
    1. After teleport trigger have been activated
    myTrigger.gameObject.name == "Player Minifig"
    We need to turn off the Minifig Character Controller (see pic.)

    player2.GetComponent<CharacterController>().enabled = false;
    2
    . the LEGO Minific is being teleported
    player2.transform.position = player.transform.position + offset;

    3. We need to turn on the Minifig Character Controller
    player2.GetComponent<CharacterController>().enabled = true;
    4. don't forget to add a line at the beginning

    using Unity.LEGO.Minifig;
    The script is available here: https://github.com/hilux5/Unity.git




    using System.Collections;
    using System.Collections.Generic;
    using Unity.LEGO.Minifig;
    using UnityEngine;

    public class Trigger : MonoBehaviour
    {
    public GameObject player;
    public GameObject player2;
    private Vector3 offset = new Vector3(10, 0, 25);


    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }
    void OnTriggerEnter(Collider myTrigger)
    {
    if (myTrigger.gameObject.name == "Player Minifig")
    {
    Debug.Log("Box went through!");
    player2.GetComponent<CharacterController>().enabled = false;
    player2.transform.position = player.transform.position + offset;
    player2.GetComponent<CharacterController>().enabled = true;

    }
    }


    }
     

    Attached Files:

    Last edited: Jan 8, 2021
  5. superUFO

    superUFO

    Joined:
    Dec 20, 2020
    Posts:
    25
    add VideoCam in LEGO Minifig teleport
    1. Add the Camera and New Rendered Texture
    upload_2021-1-4_18-3-52.png

    2
    . add New Rendered Texture teleported box
     
    Last edited: Feb 10, 2021
  6. superUFO

    superUFO

    Joined:
    Dec 20, 2020
    Posts:
    25
    a Console:
    There are 2 audio listeners in the scene. Please ensure there is always exactly one audio listener in the scene.
    to solve the problem, you need to turn off the Teleport camera sound - Audio Lestener upload_2021-1-8_12-56-53.png
     
  7. deathtome

    deathtome

    Joined:
    Oct 2, 2014
    Posts:
    6
    I so want a teleport brick as well!!!
     
  8. superUFO

    superUFO

    Joined:
    Dec 20, 2020
    Posts:
    25
    is this a joke? Please see my teleport's video!
     
  9. deathtome

    deathtome

    Joined:
    Oct 2, 2014
    Posts:
    6
    I did its not the teleporting brick that I'm looking for, would rather not have a render texture or an extra camera.

    I would rather have a brick that when stacked onto other lego bricks would either

    A. teleport the players from one spot to another spot that's been linked to each other
    or
    B. teleports the players to a new scene but doesn't count as a win, this would be helpful for a hub like level where players can jump into a different number of ports and then enter a level. think like Mario for the Nintendo 64.
     
  10. superUFO

    superUFO

    Joined:
    Dec 20, 2020
    Posts:
    25
    I have no any Nintendo
     
  11. superUFO

    superUFO

    Joined:
    Dec 20, 2020
    Posts:
    25
    My script TrigerNewScene please:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.SceneManagement;

    public class TrigerNewScene : MonoBehaviour
    {
    public GameObject player2;
    public string sceneName = "";

    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }
    public void LoadScene()
    {
    SceneManager.LoadScene(sceneName);
    }

    void OnTriggerEnter(Collider myTrigger)
    {
    if (myTrigger.gameObject.name == "Player Minifig")
    {
    Debug.Log("Minifig went through!");
    player2.GetComponent<CharacterController>().enabled = false;

    LoadScene();

    player2.GetComponent<CharacterController>().enabled = true;

    }
    }

    }
     
    Last edited: Feb 9, 2021
  12. superUFO

    superUFO

    Joined:
    Dec 20, 2020
    Posts:
    25
  13. superUFO

    superUFO

    Joined:
    Dec 20, 2020
    Posts:
    25
  14. deathtome

    deathtome

    Joined:
    Oct 2, 2014
    Posts:
    6
    Did you modify your teleport script to allow it to teleport to new scenes? cause if I'm reading the image and code correctly that's what it seems that you have done. Sorry, I'm not a coder by any means.
     
    Last edited: Feb 10, 2021
  15. superUFO

    superUFO

    Joined:
    Dec 20, 2020
    Posts:
    25
    I don't understand what the tp code is. Please see my script TrigerNewScene
    I didn't change anything, I just wrote a script and used it.


     
  16. deathtome

    deathtome

    Joined:
    Oct 2, 2014
    Posts:
    6
    Oh... lol sweet that is a very helpful script for making a hub-like world.