Hi everyone,
I’m playing with the Mouse Orbit script, and I’m trying to figure out how to set the focus of the rotation to a point other than the center of the target transform (for instance, at some user-defined point on the target, or at a point that’s coded in the script).
Any help would be very much appreciated!
Thanks
The key is the line
var position = rotation * Vector3(0.0, 0.0, -distance) + target.position;
You want to maniplate position in some way. The simplest is just to change the Vector3 there…“Vector3(15.0, 0.0, -distance)” would move the focus 15 units over to the right, for example. A more flexible way would be to put
var addToPosition : Vector3;
at the top of the script, and change the other line to
var position = rotation * Vector3(0.0, 0.0, -distance) + target.position + addToPosition;
Then you can edit the values of addToPosition in the inspector, and the focus will be offset by that amount. The important thing is just to add another Vector3 in there some way.
–Eric
Looks like that did the trick. Thanks very much, Eric!