Answer the question
In order to leave comments, you need to log in
Why is one object moving faster than the others?
Here is the behavior.
The bottom line: I move one object, and broadcast the rest by how much and in what direction this object was shifted. However, the object that I move initially - moves faster than the rest.. I can not understand why.
//Объект который двигаю
void OnFixedUpdate()
{
if (IsDragged)
{
var lastPosition = transform.position;
direction = cursorPosition - (Vector2)transform.position;
transform.Translate(direction * Time.fixedDeltaTime * dragSpeed);
if (OnDragEvent != null)
OnDragEvent(this, transform.position - lastPosition);
}
}
//Список объектов повторяющих движение. Метод вызывается при генерации события OnDragEvent
void TranslateDrag(IDragable obj, Vector2 v)
{
for (int i = 0; i < groupObjects.Count; i++)
{
if (groupObjects[i] != obj)
(groupObjects[i] as SelectableComponent).transform.position += (Vector3)v;
}
}
Answer the question
In order to leave comments, you need to log in
if (groupObjects[i] != obj)
(groupObjects[i] as SelectableComponent).transform.position += (Vector3)v;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question