L
L
LittleBob2021-12-11 17:47:09
Unity
LittleBob, 2021-12-11 17:47:09

How to implement the change of objects for management?

Let's say I have a circle, a square, and a triangle on the same scene at the same time. And there is a script for moving the object. How to make it so that by clicking on the circle I control the circle, by clicking on the square - the square, and so on?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mustGamedev, 2021-12-11
@mustGamedev

Throw a raycast from the middle of the screen to the desired target.
If the beam hit the object, then turn on its control. And do this for three objects. Of course, at the moment control is turned on for one object, control is turned off for all others.

N
Nekit Medvedev, 2021-12-13
@NIKROTOS

As an alternative to the previous answer, you can use a trigger on the cursor to get the object.
And if each object has a separate button, you can control the required objects from the control object, on which the selection script is registered (provides a link to the object) and the control script (controls the required object).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question