I am building a game using the Create...primitives commands (CreateCube, etc). I first created a camera, set ambient light, and then a couple of planes for ceiling and floor. After creating and positioning my meshes (using PositionEntity). I checked the position of my camera (pcam) using EntityX(pcam), EntityY(pcam), and EntityZ(pcam), I had a "what the...?" revelation: my camera was nowhere the starting x-y-z positions I had set for the camera. Instead of being at PositionEntity pcam, x=20,y=0.25,z=16, I was sitting at 4.718374, -1.17, and 5.13543. My reaction: "What the??" and "Huh??"
I did some testing, and found that if I checked my camera's entity position BEFORE setting up all the meshes in their respective positions, it read the correct coordinates. After setting the meshes set-ups, it read the bogus. It wasn't just a mis-read, either. My camera REALLY was at those coords. In fact, the game was starting me off inside a wall section.
I don't know what was skewing my coordinates for the camera, but I found a workaround solution: after installing all my map meshes made from the primitives, I ran the command UpdateWorld, and then used PositionEntity for the camera, and it sat exactly where I wanted it to start. Problem solved.
But...
Does anybody have any idea as to why the positioning error was occurring in the first place? I checked the code for installing the various mesh primitives, and there is absolutely no reference to the camera (ie pcam) whatsoever. So how come it was skewed to a totally bogus starting location?
I did some testing, and found that if I checked my camera's entity position BEFORE setting up all the meshes in their respective positions, it read the correct coordinates. After setting the meshes set-ups, it read the bogus. It wasn't just a mis-read, either. My camera REALLY was at those coords. In fact, the game was starting me off inside a wall section.
I don't know what was skewing my coordinates for the camera, but I found a workaround solution: after installing all my map meshes made from the primitives, I ran the command UpdateWorld, and then used PositionEntity for the camera, and it sat exactly where I wanted it to start. Problem solved.
But...
Does anybody have any idea as to why the positioning error was occurring in the first place? I checked the code for installing the various mesh primitives, and there is absolutely no reference to the camera (ie pcam) whatsoever. So how come it was skewed to a totally bogus starting location?