Reputation: 41
while following some guides to make an object move, I have this issue.
So, all objects on the scene are 0, 0, 0, on rotation except for the camera. The camera, then is 0, 180, 0. The script says - for a object to move to the left :
void Update () {
transform.Translate(Vector3.left * (ScrollSpeed * Time.deltaTime));//access transform component and moves it left by 20 times the frame rate
}
So technically it moves left, but the camera perspective is at 180 degrees to look at the game from the front. So is my only solution to rotate the platform on Y to match the perspective to make it in reverse so when working on things I dont have to keep using negative numbers to do the opposite of the actual scene?
Upvotes: 0
Views: 859
Reputation: 1893
Instead of using Vector3
static variables which are define in the world space, you can use the transform
of the Camera, so the moving directions are depending on the Camera. That is to say in your case:
void Update () {
transform.Translate(
-Camera.main.transform.right * (ScrollSpeed * Time.deltaTime));
}
Notice the -
in front of Camera.main.transform.right
, the opposite of the right direction is the left direction ;-)
If you have several Cameras in your scene, use a reference to the Camera you want instead of Camera.main
Upvotes: 1
Reputation: 41
I found the issue.
So the original scene itself was 0, 0, 0, but I needed to play the scene -180 on the Y axis and face the camera at 0, 0, 0, this way the only thing rotated is the design of the background.
Upvotes: 0