Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

195
Views
Unidad. Cómo crear una cámara giratoria alrededor de un objeto con el cambio de este objeto

Quiero hacer una cámara giratoria en el mapa alrededor del objeto de destino, con el primer punto lo hice. Después de hacer clic en otro objeto, que también quiero inspeccionar, mi cámara se desplaza y gira no alrededor del objeto, sino en algún otro punto. Cómo señalar un objeto alrededor del cual quiero que la cámara gire con el mouse

 LabsManager lab; public Transform lookCentre; public Transform lookZRU; public Vector3 offset; public float sensitivity; // чувствительность мышки public float limit; // ограничение вращения по Y public float zoom; // чувствительность при увеличении, колесиком мышки public float zoomMax; // макс. увеличение public float zoomMin; // мин. увеличение private float X, Y; bool activeTarget; void Start() { GameObject activ = GameObject.Find("LabsManager"); lab = activ.GetComponent<LabsManager>(); activeTarget = false; } void Update() { if (lab.LabName == "Осмотр") { if (activeTarget == false) { CameraPosition(lookCentre); MouseLook(); } LookZRU(); } } void CameraPosition(Transform target) { if (activeTarget == false) { transform.position = transform.localRotation * offset + target.position; } MouseLook(); } void MouseLook() { if (Input.GetAxis("Mouse ScrollWheel") > 0) offset.z += zoom; else if (Input.GetAxis("Mouse ScrollWheel") < 0) offset.z -= zoom; offset.z = Mathf.Clamp(offset.z, -Mathf.Abs(zoomMax), -Mathf.Abs(zoomMin)); if (Input.GetMouseButton(1)) { X = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivity; } if (Input.GetMouseButton(0)) { Y += Input.GetAxis("Mouse Y") * sensitivity; } Y = Mathf.Clamp(Y, -limit, limit); transform.localEulerAngles = new Vector3(-Y, X, 0); } void LookZRU() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (hit.collider.gameObject.GetComponent<SelectZRU>()) { Debug.Log(gameObject.name + " бла бла"); if (Input.GetKeyDown(KeyCode.R)) { activeTarget = true; CameraPosition(lookZRU); } } } if (activeTarget == true) { MouseLook(); } }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Puede usar rotar, simplemente actualice el valor "obj" con su nueva posición de objeto en el que hizo clic.

 Vector3 obj = target.transform.position; //change this transform.RotateAround(obj, Vector3.up, 20 * Time.deltaTime);
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!