Hi Guys,
Im trying to tween a GameObject from one position and orientation to another, the problem is the target destination is another object that is constantly shifting its position and orientation. After trying iTween unsuccessfully I wrote this code:
// percentage is a value between 0-1, for how far between the two object is
Vector3 DummyPosition = OriginDummy.transform.position;
Vector3 TargetPosition = TargetPosition.transform.position;
Phone.transform.position = (DummyPosition * (1.0f - percentage)) + ( TargetPosition * percentage);
Vector3 DummyForward = OriginDummy.transform.forward;
Vector3 TargetForward = TargetPosition.transform.forward;
Phone.transform.forward = ((DummyForward * (1.0f - percentage)) + ( TargetForward * percentage)).normalized;
Vector3 DummyRight = OriginDummy.transform.right;
Vector3 TargetRight = TargetPosition.transform.right;
Phone.transform.right = ((DummyRight * (1.0f - percentage)) + ( TargetRight * percentage)).normalized;
Vector3 DummyUp = OriginDummy.transform.up;
Vector3 TargetUp = TargetPosition.transform.up;
Phone.transform.up = ((DummyUp * (1.0f - percentage)) + ( TargetUp * percentage)).normalized;
which almost worked but one of the axis is off, I think the problem is that the forward,up etc. values are local, where as I need global axis. But I could be wrong, but surely there’s a much better way to do this?
Thanks for any help