can someone know whay when i switch to playmode the camera change it position to the middle of the prefabe? how do i fix it so the camera stay on the top of the prefab?
Do any of your scripts affect the camera location?
no…
UP
You dont need to bump a post just because you didnt get an answer in 4(!) hours since the last post, adding multiposting to the offense. None of that is supposed to be done, but at the very least wait 1-2 days(!) before bumping a thread.
As for your problem. Your screenshots cut out most of the information. If you are using any script, maybe post them. In fact, in your screenshot there is at least one script that indicates it’s manipulating the camera - so posting that is where you could start providing some information.
Objects should not reset their position by themselves. Either you are spawning in a new one, editing the position via a script, make some error result in a wrong position, edit the prefab at runtime, simply edit the position at runtime and then end the run which resets the position, or…, or… there are a gazillion things which may cause this problem, but i’d personally need more information provided before i can offer meaningful help. And the most likely cause is that it’s a script causing this, namely the one doing camera controls.
Ok sorry, here is more details…I even made a new scene and its make the same problem. im attaching 4 photos. 2 refer to the player and the other 2 to the camera so you can see all of the details.
here is the script of the Gvr Editor Emulator (“Player”) which is a prefab from the google vr pack:
public class NewBehaviourScript : MonoBehaviour
{
public Transform vrCamera;
public float toggleAngle = 30.0f;
public float speed = 3.0f;
public bool moveForward;
private CharacterController cc;
// Start is called before the first frame update
void Start()
{
cc = GetComponent<CharacterController>();
}
// Update is called once per frame
void Update()
{
if (vrCamera.eulerAngles.x >= toggleAngle && vrCamera.eulerAngles.x < 90.0f)
{
moveForward = true;
}
else
{
moveForward = false;
}
if (moveForward)
{
Vector3 forward = vrCamera.TransformDirection(Vector3.forward);
cc.SimpleMove(forward * speed);
}
}
}
and thats it…no more script…only what you see in the screen shoots.




Remove the character controller and see if this still happens. If so, the issue is with your cc, which may do some initialization to your camera.
without the character controller the player cant move. but even without the character controller its change the position as shown in the pictures
Edit:
Ok, found the solution. character controller oY offset value sould be -1 and thats it.
I noticed that the transform.position.y of your camera get set to 0 in play-mode.
I would try the following:
Create an empty gameobject as child of your player. This will be the pivot position for your camera (move it to whereever you want to camera to be looking at). Then add the camera to this gameobject (Make sure the transform.position of the camera remains at 0).
Can’t test it right now though - just a thought!

