Hello,
I create a SolarSystem Simulation and I want if I click on the Text over the Planet switch to the Planet. I have a script for zoom around the Sun. In this Script is a target for the orbiting for the camera and I don’t know how to change the target to the Planet (GameObject)
I need a code to change the target from a script in a other script.
My idea:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ClickMercury : MonoBehaviour
{
void Update() {
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
if (hit.transform.name == "MercuryText")
{
// Here is the Problem
GameObject.Find(MainCamera).GetComponent<ZoomCamera>().target = gameObject;
}
else
{
}
}
}
}
Thanks for help!