Quantcast
Channel: Questions in topic: "portals"
Viewing all articles
Browse latest Browse all 85

2D Linked Portals

$
0
0
Hello, I'm working on a 2D game and I added linked portals to it. For instance if I stand on top of portal A and press the teleport button, I get teleported to portal B. And if I stand on top of portal B and press the teleport button, I get teleported to portal A. The problem is that one of the portals works and the other doesn't for some reason... The script attached to both of them is the following: using System.Collections; using System.Collections.Generic; using UnityEngine; public class telep : MonoBehaviour { private GameObject player; public GameObject Destination; // Use this for initialization void Start () { player = GameObject.Find("Player"); } // Update is called once per frame void Update () { if ((player.transform.position.x > (transform.position.x - 0.5)) && (player.transform.position.x < (transform.position.x + 0.5))) if (Input.GetButton("Teleport")) { player.transform.position = new Vector3(Destination.transform.position.x, Destination.transform.position.y, 0); } } } Here is a video to better understand the problem: https://www.youtube.com/watch?v=XwFmILYMCWE

Viewing all articles
Browse latest Browse all 85

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>