Reputation: 85
I am new to Unity and am a bit puzzled on how i would go about doing this. I have a model of a stick that the camera will follow endlessly up and down along the Y axis, and be stationary along the X axis. What i am trying to accomplish is this: when the model goes passed the right side of the camera view, it will appear on the left side. and i will do the same when it goes passed the left side. here is a very rough image depicting what i would like to accomplish
I just need help with the model teleportation, not the camera following the model.
Upvotes: 2
Views: 889
Reputation: 85
Here is my solution (thanks to AustinWBryan)
if (IsOutOfBounds(active))
{
inactive.position = new Vector3(0,0,0);
inactive.rotation = active.rotation;
inactiveRB.velocity = new Vector3(0,0,0);
inactiveRB.angularVelocity = activeRB.angularVelocity;
activeSword.SetActive(false);
inactiveSword.SetActive(true);
}
Upvotes: 0
Reputation: 3326
What you can do is, once the model begins to exit the screen, spawn another instance of it on the other side and transfer the stats. Now, when one moves, the other one moves, and it creates the illusion it's being wrapped around.
When one of them exits the screen it gets destroyed.
If it's expensive to create multiple instances so often, then you can just use only two instances, and disable/reenable based on where it is on the screen.
Upvotes: 1