Main camera change position when "Play" Button hit

Hi fellow Unity users,

I am a medical student and I need unity to create a set up for research purposes.

I have created a very simple 3D environment, which we will later use with the HTC Vive Pro 2.0. But for now in the testing phase I’m working with the main camera. My problem is that it moves as soon I hit the play button. I’ve attached two screenshots. Does anyone know why this happens?

Thank you in advance


Same problem but represented in a .gif

4439446--406243--4e73a7bd6933b395318cd57a2331b316.gif

Hard to see what is happening without more info.
Select your main camera and look at what the inspector is telling you.
What happens to the position of the camera (transform) when you enter play mode?
Is there a script on the camera?
Is there a script somewhere else?

1 Like

Thanks for your quick reply. Much appreciated. I’ve added the gif with the inspector on the main camera, also a screenshot of the inspector on the game object. There is a script which receives signals from another computer which I run LabVIEW on. Can I provide you with any more information?


4439602--406267--gif inspector main camera.gif
4439602–406270–networkCon1.cs (4 KB)

If i see it correctly, it looks like your camera isn’t moving.
There is a script on the camera but it’s disabled and the position of the camera appears unchanged when you enter playmode, from what i can see.
The same script is also on the parent of the spheres and is active.
I looked at the script and there is some position stuff happening there.
I have no idea what this script is for, but in the Update function there is :
transform.position = pos;

So, my guess is that this script is your issue.
Try disabling it on the “GameObject”.

1 Like

The script was the issue indeed, but I need the script to update the position. Should I configure the script? Or better said, as I don’t know how to configure it, ask somebody to debug it?

Ok, cool.
I would ask for help. This is not a “basic” script and without more knowledge i think you’ll have a hard time figuring it out.

I’m guessing that
pos = StringToVector3(dataReceived, index1); is returning a different Vector3 than you expect.

The issue could be in the data received via TCP, it could be an issue in the parsing of the data (for some reason you’re receiving the data as a string then converting it to a Vector3 instead of just receiving 3 floats directly and creating a Vector3 from them), or everything is working correctly but the Vector3 is resulting in a pos far enough from the camera so it is outside its view.

I’d first verify that the sender is sending a position update that is going to place the object in front of the camera. If that is not the case, just reposition the camera so the object remains in view, or write a script where the camera will follow the movement of the object.

If that is not the problem you’ll need to debug the data received via TCP, the resulting string, the parsed Vector3 from the string, and figure out where things are going wrong. You apparently didn’t write the script, so it might be easier to just talk to whoever did write it.

I had a similar issue on a game I was building . Issue was , it seemed as if the camera was moving up. But actually as the Rigid body had default Gravity on for Plane and Obstacles , all the objects excluding the camera was moving down. Once I deselected the Gravity on both the plan and the Obstacles, it was all ok