Parent - chield problem.

Here is the problem. I have an empty GameObject with Main Camera child. If I rotate camera by itself rotation of panet object must be the same, but it’s not true. Here is what I want to do.

  1. Rotate camera and then be able to move it left and rigth up and down with it’s X and Z axis.

As I’ve investigated rotation works on X axis, and Z, Y rotates around it.
If when I try to move camera along X it’s work fine because position of X itn’t changed, but if on Z direction of movment is wrong. So I decided to pleca camera in another object rotate camera and move object and in theory this may help. But it’s not. Any suggestion?

sure it is true. The rotation of the parent object won’t change if you rotate the children. You must have a mistake in your logic.
you can also use transform.up, transform.right, transform.forward to move in “object’s space”

I need your advice. I have object A and Main Camera inside of it. In my code: I rotate Main Camera and move object A, but it’s not working propertly. 699230–25191–$MouseCamera.cs (3.68 KB)

still not sure what you are trying to achieve, but maybe try

                                                                Vector3 moveH = Vector3.right * h; 
				Vector3 moveV = Vector3.forward * v;
				
				Debug.Log(moveH + "   "+  moveV);
				if((screenPos.x <= 900.0f  moveH.x < 0.0f)
				   || (screenPos.x >= 80.0f  moveH.x > 0.0f)
				   )
				{
					transform.parent.Translate(moveH , Space.World);
				}
				if((screenPos.y <= 500.0f  moveV.z < 0.0f)
				   ||(screenPos.y >= 60.0f  moveV.z > 0.0f))
				{
					transform.parent.Translate(moveV, Space.World);
				}

or

                                                                Vector3 moveH = transform.right * h; 
				Vector3 moveV = transform.forward * v;
				
				Debug.Log(moveH + "   "+  moveV);
				if((screenPos.x <= 900.0f  moveH.x < 0.0f)
				   || (screenPos.x >= 80.0f  moveH.x > 0.0f)
				   )
				{
					transform.Translate(moveH , Space.World);
				}
				if((screenPos.y <= 500.0f  moveV.z < 0.0f)
				   ||(screenPos.y >= 60.0f  moveV.z > 0.0f))
				{
					transform.Translate(moveV, Space.World);
				}

I already tyred this kind of code, but when you rotate the camera then it move wrong

one more guess :slight_smile:
sorry, I can’t try it right now.

                                                                Vector3 moveH = transform.right * h; 
				Vector3 moveV = transform.forward * v;
				
				Debug.Log(moveH + "   "+  moveV);
				if((screenPos.x <= 900.0f  moveH.x < 0.0f)
				   || (screenPos.x >= 80.0f  moveH.x > 0.0f)
				   )
				{
					transform.position += moveH;
				}
				if((screenPos.y <= 500.0f  moveV.z < 0.0f)
				   ||(screenPos.y >= 60.0f  moveV.z > 0.0f))
				{
					transform.position += moveV;
				}

Sorry for wrong text.) In your code Vector3 moveV = transform.forward * v; I’ve tested it and it’s not what I want because it zoooms camera. I need to move camera up and down on screen in the same way as left and rigth.

ok, so if you do Vector3 moveV = transform.up * v instead, does it work?

Thank you for staying with me. Here is the case. yes it did it like this, but still the same problem Z axis change it’s position during previouse rotation and then camera movement became strange. It need to move up and down like left and rigth, but in our case it’s moves left and rigth but by diagonal depending on previous rotation angle.