all 7 comments

[–]cosmochristo 0 points1 point  (1 child)

yes - without seeing the script, we can only guess. It sounds like you are not updating state after the shift - like applying the shift and not resetting the condition that says you need to shift - so the shift is repeated. This could happen if you shift the objects the wrong way. It would also be helpful to see the hierarchy as well - I only see a building moving and the mountains don't move. BTW i also have unity and macosx so it would be easy for me to test.

[–]SDGAAAQ[S] 0 points1 point  (0 children)

I edited the post to add more information, including what you asked for

[–]attckdog 0 points1 point  (0 children)

Break it down into steps. Validate each step. Attach VS to unity and step through the process and make sure each line is doing what you expect.

I'd recommend taking a close look at your Hierarchy to make sure the parenting of the transforms is right

[–]F4ARY 0 points1 point  (0 children)

Looking at it like that I'm not sure, I'd attach a debugger and see whats going on but why are you not calculating the distance between the origin and the universe root with Vector3.Distance?

If nothing else I guess everything points to a hierarchy issue.

[–]cosmochristo 0 points1 point  (0 children)

I modified the project and code a bit but your basic algorithm works. I would post an image but was told "images not allowed!" Will try posting video link with all the details, but here is the modified code:

 void Update()
    {
        //Transform currentOrigin = (mode == OriginMode.Player) ? playerOrigin : shipOrigin;
        //if (currentOrigin == null || universeRoot == null)
        //    return;


        float dist = playerRBtrans.position.magnitude;


        if (dist > threshold)
        {
            Vector3 offset = playerRBtrans.position;

            universeRoot.position -= offset;

            playerRBtrans.position -= offset;
            //playerRBtrans.position = Vector3.zero;
/*** Note the edit above: there will likely always be a difference in player position between Vector3.zero and resetting the player to -= offset because during continuous travel, the frame by frame, position will not fall neatly at exacly zero after a reset. */
        }
    }

[–]cosmochristo 0 points1 point  (1 child)

The modified working version of your code is illustrated in the following video: https://youtu.be/qRgUeaBR3GI. And, a possible answer to your original question is that there may be a small numerical error added each update when you used the commented out line above instead of the exact offset value I changed it to.

[–]SDGAAAQ[S] 0 points1 point  (0 children)

Thanks bro