Measure distance between a fixed object and a moving prefab?
(ENG) Help ...
I need to make a scoring system based on the distance between two balls. One of them serves as a reference and the other is a prefab that, when instanced, will be thrown to that reference ball. Among the many attempts I made, measuring the distance between objects never worked. First, I had imagined that the fact that the prefab was not instantiated at the beginning of the execution was the problem, however, even with the use of an "OnTriggerEnter" so that the code would only execute after the detection of an object (ball) in a certain area, the error still kept showing up. After that, I would like to understand what my mistake is, or if there is any other way to resolve this situation.
Attached is a .pdf file to better illustrate the code and the problem
Thanks in advance!
(PT/BR)
Eu preciso fazer um sistema de pontuação baseado na distancia entre duas bolas. Uma delas serve como referência e a outra é um prefab que ao ser instaciada, será arremessada até essa bola de referencia. Dentre as diversas tentativas que eu fiz, a medição da distancia entre os objetos nunca funcionou. Primeiramente, eu havia imaginado que o fato do prefab não ser instanciado logo no início da execução era o problema, contudo, mesmo com o uso de um "OnTriggerEnter" para que o código só executasse após a detecção de um objeto (ball) em um determinada área, o erro ainda continuavga aparecendo. Depois disso, eu gostaria de entender qual é o meu erro, ou se existe alguma outra forma de resolver essa situação.
Segue em anexo, um arquivo .pdf para ilustrar melhor o código e o problema link text
Desde já, muito obrigado!
Your answer
![](https://koobas.hobune.stream/wayback/20220613031657im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Collision Triggers at Random 1 Answer
How do I detect a collision between two objects using Bolt? 1 Answer
how to make particles NOT collide with triggers? 1 Answer
How to make an object stop when the distance between it and another object reaches 0 ? 1 Answer
OnTriggerExit() and OnTriggerEnter() Called When Character Jumps, All In One Frame 1 Answer