Send Vector3 of a Instanz to a another Script. Need some Help ...

Hey.

I try to spawn a GameObjekt (Target). With the Target a UI Button Spawn. When this Button is pressed the Camera should jump to the position of the Target!

I have a TargetController Script:

using UnityEngine;
using System.Collections;

public class TargetController : MonoBehaviour {
    private bool ButtonPressed;
    public GameObject kamera;


    void Update(){
        kamera = GameObject.Find("Kamera");
        if (ButtonPressed) {
            kamera.SendMessage("ButtonPressed");
        }
      
    }
  
    //UI activation
    public void Button() {
        ButtonPressed = true;
    }
}

The UI Button triggers “public void Button”. Then the script finds the Kamera GameObject and send a message.

the “Camera Jump to Target” Part of the CameraController:

        //Camera should Jump to Target.
        if (CameraJumpTarget) {

            Vector3 TargetJumpXY = new Vector3(TargetPosition.x, TargetPosition.y, -50f);
            transform.position = TargetJumpXY;

            if (transform.position == TargetJumpXY){
                CameraJumpTarget = false;
            }

        }

The Camera Jumps. But only to Position 0,0,0.

I need to Send the Position of the GameObjekt “Target” to the Camera. Its a Prefab. So a lot of them will be arround later. If i let the Camera get the Position of the Target the Script will habe a lot of identical Targets!

I need a Posibility to SEND the Target Position (Vector3) to the Camera.

Inside TargetController, use GetComponent() on your Kamera object to access the CameraController script and then assign it the intended target position.

Wohh Thanks for your Help ^^
After 2 Days it works.