Skip to main content
New Participant
February 25, 2017
Solved

How do you fix a teleportation point in space relative to a moving object?

I slapped a teleportation point as the child of a sphere, which I can move around my scene and teleport to, but there are still a few issues to work through:
- the ColumnGlow of the teleportation point swings around wildly as the ball rolls around the scene.
- the orientation of the player following teleportation is the same as the sphere, so it's basically random and very disorienting.
- If the ball rolls out of sight, you can't teleport at all.

Ideally, I'd like to lose ColumnGlow altogether and have a press of the A button teleport the player to a spot just slightly off to a side of the ball.

I assume this is a pretty easy thing, but I'm a terrible coder, so I thought I'd seek out a little help.

Thanks in advance!
This topic has been closed for replies.
weasel47Answer
Inspiring
February 27, 2017
If you're only changing the player's transform.position and not rotation, the player's rotation won't change.

8 replies

New Participant
February 26, 2017
I managed to get rid of ColumGlow just by unticking the Mesh Renderer. Now Ijust need to fix the orientation of the teleport point and make teleportation line-of-sight independent. Any help is mightily appreciated.
Inspiring
February 27, 2017
I don't know what ColumnGlow is,  but....

If you have an object in the position you want the player to teleport to, all you have to do is change the player's transform.position by setting it equal to the other object's transform.position 
New Participant
February 27, 2017
I will try this, but I think this is essentially how Oculus' teleport script works, and I think I'll run into the same problem. Since the player is following a ball, the player rotation after teleport is the same as the ball, which is to say essentially random. I think I need to use a Vector3 to counteract this, but I'm not entirely sure, and I'm always glacially slow at coding, but I make up for it by also being bad at it. Does using a Vector3 sound like a possible solution to you?
weasel47Answer
Inspiring
February 27, 2017
If you're only changing the player's transform.position and not rotation, the player's rotation won't change.
New Participant
February 28, 2017
I appreciate your help, but I'm having no luck so far. The script itself is very straightforward. Maybe you could tell me which line to add the transform.position? I've tried all the things I think would work, and have gotten it wrong every time. Here's the script Oculus uses for its Teleport points:

using UnityEngine;
using System.Collections;

public class TeleportPoint : MonoBehaviour {

    public float dimmingSpeed = 1;
    public float fullIntensity = 1;
    public float lowIntensity = 0.5f;


    public Transform destTransform;

    private float lastLookAtTime = 0;



// Use this for initialization
void Start () {
}

    public Transform GetDestTransform()
    {
        return destTransform;
    }
   


// Update is called once per frame
void Update () {
        float intensity = Mathf.SmoothStep(fullIntensity, lowIntensity, (Time.time - lastLookAtTime) * dimmingSpeed);
        GetComponent<MeshRenderer>().material.SetFloat("_Intensity", intensity);
    }

    public void OnLookAt()
    {
        lastLookAtTime = Time.time;
    }
}

Simple, right? Just not for me.
Inspiring
February 28, 2017
I'm guessing another script is calling the GetDestTransform function from this script?  Over in that other script is where a change would need to be made...
New Participant
February 28, 2017
Yep. Totally correct. I found the function in another script, commented out the line dealing with rotation, and now I'm 90% of the way to having it working to my satisfaction. Thanks so much! You're a hero!

Inspiring
February 28, 2017
You're welcome, I'm glad I could help!