Hello Unity folks,
I am trying to create a Teleporter which is able to feel the location of collision and transform the place of impact to the same place on the second exit teleporter (Like the 3d plane collider). I have tried multiple scripts and tutorials but I cannot come up with any solution. Most of the tutorials were meant for 3d projects.
The teleporter pad is stretched from left to right. The collision will be from under as my player is floating upwards.
I have tried to use the 3d plane collider but got an error because I couldn't use it with the 2d physics engine of unity.
I appreciate any help as this is really a struggle for me.
With kind regards and thanks in advance.
How about some pictures or something? Screenshots? I think I get what you're asking, but without knowing/seeing more to be certain, I don't want to waste our time.
If I understand, you can use your collision event's contacts. On collision, transform the first contact into local space, set the teleported object's position to the other pad's position + the transformed point-of-contact.
I have added a screenshot to be more clear about the problem. Is this clear enough?
Answer by AlwaysSunny
·
Feb 09, 2015 at 04:15 AM
I think so. Screenshots / diagrams always help. If these pairs-of-teleporters always share the same size and orientation, the easiest solution might be...
//OnTriggerEnter
Vector3 offset = object.position - teleporterA.position;
object.position = teleporterB.position + offset;
Might have the offset backwards, I'm a little decaffeinated. If teleporters didn't share orientations, things might get interesting. Lemme know if this works out, and good luck,
using UnityEngine;
using System.Collections;
public class Teleporter : MonoBehaviour {
public object TeleportTo;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter (Collider other) {
Vector3 offset = object.position - teleporterA.position;
object.position = teleporterB.position + offset;
}
}
Something like this? I am missing some connections because I get a lot of red references. I am not really experienced with scripting I am a beginner, sorry .
Making my 2d character's arm follow the mouse, scrpit not working, please help :c
1
Answer
Emerging Gap when moving my "Snake"
1
Answer
How can i fix a position of a gameobject after it meets its condition
1
Answer
Character rotation and move to mouse click point with speed
0
Answers
How to create a player movement with Rotation?
1
Answer