S
S
Sergey Izmodenov2021-02-01 21:19:54
Unity
Sergey Izmodenov, 2021-02-01 21:19:54

How to get collider coordinates?

I need to make it so that when entering an object with a trigger, another object moves to the center of the collider of this trigger, tries different methods, but they all transfer the object not to the trigger collider, but to the object to which the trigger is attached. Tried move methods to:
1. other.transform.position (Trigger collider name other)
2. transform.position
3. transform.GetComponent().transform.position

Searched on different forms but couldn't find a solution anywhere how to do this ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GavriKos, 2021-02-01
@GavriKos

The collider coordinates are the same as the object coordinates.
The only time they might not match is if there is a collider offset. Then we need to add this offset to the coordinates of the object.
And even better - do not use such a garden and separately from everything set the coordinates where you need to move the object

C
CHIDWI, 2021-02-05
@CHIDWI

Colliders/triggers and stuff are components. They are hung on the GameObject and it already has coordinates to which you directly move. You need to create an empty GameObject where you want to move it. Well, hang a trigger or collider on it there, whatever you need.
ps A collider within a collider is a bad idea.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question