0
votes

I am making an ar solar system app and i am right now able to augment whole solar system without any issue but what I want is to provide a menu to user so he can select planets from menu and when he select camera instead of showing all move closer to specific planet say Jupiter so user can view and concentrate on one object at one time ...so basically I want to move the camera so close to a specific planet that rest don't show

3

3 Answers

0
votes

Could you not move camera towards a specific planet and increase the distance of other planets from the chosen planet?

Pseudo code: Assuming your planets are scattered across the x axis

user clicks on the planet
  move camera towards planet
  foreach planet in planets
    dir = (selectedPlanet.transform.position - planet.transform.position).normalized
    if(dir < 0)
      //means the planet is to the left of selected planet
      planet.transform.position.x -= 10;
    else
      // planet is to the right of selected planet
      planet.transform.position.x += 10;  

I'm not on a PC with unity3d so apologies for typos in advance.

0
votes

I recommend since is for AR that you scale and move the planets instead of the camera.

Leave the camera as it is, but when a planet is clicked, scale the planet (or planets) object to get them closer to the view of the user.

You can do this easily with the animator.

0
votes

The AR camera cannot be moved since you have the control of it and hence the position and rotations depends on real world space and not from the game view. So instead of trying to move camera (which is not possible), try making the planets come closer to the camera. That is, use the position of camera as a reference and thus you can easily bring each planet closer to the camera. Transform.LookAt() and Vector3.MoveTowards() can be used here

void Update()
{
   planet1.transform.LookAt(ARCam.transform); // this is so that the planet will rotate towards the camera and then using Vector3.MoveTowards() it will move towards the camera.
}
void Update()
    {

        planet1.transform.position = Vector3.MoveTowards(planet1.transform.position, ARCam.transform.position, speed*Time.deltaTime);
    }