So I’m trying to implement a 3d shield. For it, I’m using the orbit script at the wiki that is usually for cameras.

It works pretty good except that each time that I re-initiate control of the orbit the shield just resets to some position, insted of starting where it left off. The problem is the x variable in the following code:

```
Quaternion rotation = Quaternion.Euler(y,x, 0);
```

The object is a child of an object. I manipulate it when I press mouse button1.

I was trying to pass the x value of the parent.transform.rotation.y but this would not do it Any ideas?

Here is the full code of the manipulation. Thank you for the time!

```
void LateUpdate()
{
if (it && Input.GetKey (powerControll)) {
Orbit ();
}
}
void Orbit()
{
if (Input.GetMouseButton (1)) {
x += Input.GetAxis("Mouse X") * xSpeed * distance * 0.02f;
}
y = at.myArm.transform.localEulerAngles.x *-1;
Quaternion rotation = Quaternion.Euler(y,x, 0);
Vector3 negDistance = new Vector3(0.0f, 0.0f, -distance);
Vector3 position = rotation * negDistance + at.myBall.transform.position;
it.transform.rotation = rotation;
it.transform.position = position;
}
```

When you call

```
it.transform.rotation = rotation;
```

you are setting the rotation to some value which never took into account the initial rotation of the shield. ie. Look at your definitions of `rotation`

and `x`

. They don’t look at the transform of the shield.

What you have defined (I think, because I don’t know what `at.myArm`

is) is how much you want to offset the shield this frame. To clarify, if x equals the change in mouse position this frame times some speed, then you probably want to map that to the change in shield rotation this frame. What you are doing now is setting it equal to the actual rotation value of the shield which will always start based around 0.

Try calling this instead:

```
it.transform.Rotate(rotation);
```

If the rotation is still somehow incorrect, either go back and look at your definition of y (I only say this because its based on something I can’t see in your code) or try:

```
it.transform.Rotate(rotation, Space.Local);
```

or

```
it.transform.Rotate(rotation, Space.World);
```

Hi there, Thank you for your time. I coulden’t use your methood because I was multiplying a Quaternion by a Vector, so I coulden’t just rotate.

I just managed to find a solution. I checked the parameters as you suggested, and I found that I could pass the x, as the current euler Anlges of the shield, in the y axis… Thank you again XD

```
x = (it.transform.eulerAngles.y - 360);
```