I know there might be a simple way of doing this. But ive been killing myself the last couple days to figure it out. So what I basically need if for my camera to rotate around an object when i press The left arrow key or the right arrow key. That was simple, the hard part was how can i make it also follow the object at a certain distance. Because when I use the 2 scripts together, my object just goes wild and moves in all places. If there is a simple way to use this, please help me. And also my object is a RigidBody so it does a lot of rolling around and such.
This is my rotating script. Now how can I use this and also make the camera follow my objects movement.
function Update()
{
for (var touch : Touch in Input.touches)
{
if (rightrot.guiTexture.HitTest (touch.position))
{
// rotate left
transform.RotateAround (target.transform.position, Vector3.up, 7 * Time.deltaTime);
}
if (leftrot.guiTexture.HitTest (touch.position))
{
// rotate left
transform.RotateAround (target.transform.position, -Vector3.up, 7 * Time.deltaTime);
}
}
}
↧