1 (edited by alexandra 2017-01-16 09:24:20)

Topic: Teleport and moving the map

Hi!
We are using a basic teleport script to move across te map (specifically VRTK Basic Teleport), but the problem is that the player literally teleports to that position on the plane and the image on the plane itself does not move. This means that eventually the player ends up at the border of the plane.
Attached are two images to show what I mean.

Is there an easy way to compensate the map so that it takes the current player position and resets itself so that position is now the middle? Or should I try to modify the teleport script to do this instead?

I have already tried to do this instead of moving the player on teleport:
            double lng, lat;
            OnlineMaps map = OnlineMaps.instance;
            map.projection.TileToCoordinates(target.position.x, target.position.z, map.zoom, out lng, out lat);
            map.SetPosition(lng, lat);

But this gives a strange result, the lng, lat is not as expected.

Post's attachments

Attachment icon Screenshot_7.png 165.47 kb, 279 downloads since 2017-01-16 

Re: Teleport and moving the map

And the second image

Post's attachments

Attachment icon Screenshot_8.png 62.88 kb, 284 downloads since 2017-01-16 

Re: Teleport and moving the map

Hello.

You need to change the location of map (map.SetPosition) instead of the position of the map GameObject.
Send me your teleport script. I will try to modify it for you.

Or you can do to map GameObject follow to player GameObject.
To do this:
1. Teleport.
2. Get the coordinates in the player position (OnlineMapsTileSetControl.GetCoordsByWorldPosition).
3. Set the new map coordinates (map.SetPosition).
4. Update map.transform.position, so center of map was under player position.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Teleport and moving the map

Hi! I've tried doing what you said but I guess there's still something I'm not quite getting as the player ends up outside of the map boundaries.
Attached is the VRTK library Teleport script. You can find the code I added by searching for "Added code by Alexandra". Thank you so much again for your help smile

Re: Teleport and moving the map

Hello.

Your post does not contain a script.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Teleport and moving the map

It seemed I had chosen a file, but not clicked "Add file" orz

Post's attachments

Attachment icon VRTK_BasicTeleport.cs 11.81 kb, 483 downloads since 2017-01-17 

Re: Teleport and moving the map

I made corrections in your code.
Of course, it is not tested, because I do not have VRTK.
But, theoretically, it should work.

protected virtual void SetNewPosition(Vector3 position, Transform target)
{
    transform.position = CheckTerrainCollision(position, target);
    ///// Added code by Alexandra
    Vector3 p = transform.position;
    double lng, lat;
    OnlineMaps map = OnlineMaps.instance;
    OnlineMapsTileSetControl.instance.GetCoordsByWorldPosition(out lng, out lat, p);
    map.SetPosition(lng, lat);
    map.transform.position = new Vector3(p.x + map.tilesetSize.x / -2, map.transform.position.y, p.z + map.tilesetSize.y / 2);
    ///// End code added
}
Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Teleport and moving the map

It didn't work at first, but I changed the '+'s in "(p.x + map.tilesetSize.x / -2, map.transform.position.y, p.z + map.tilesetSize.y / 2);" to '-'s and now it works!!! Thank you sooo much!!

Re: Teleport and moving the map

I just wanted to post and say thanks because this totally helped with an issue I was dealing with. Thank you!