Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

298
Visualizações
Why is my raycast hit point expected output different to the actual output?

I have been trying to make a character controller with inverse kinematics, and I am using ray casts to determine the target points for the bones to attach to, but I am having some issues with the ray casting hit information being changed.

What exactly is happenning? Well I am shooting out a raycast in the direction that the raycast point is facing. Once it hits the ground, it sets the anchor position to the hit point position. Except for the fact that my anchor point position is completely different to my hit point position even after the raycasting.

public Transform[] anchors;
void RayOut()
{
    RaycastHit hit; // Create Ray Instance
    if (Physics.Raycast(transform.position, transform.forward, out hit)) // Launch The Instance
    {
        Debug.DrawLine (transform.position, hit.point);
        switch (gameObject.name) // Check This Name & Assign Positions
        {
            case "TR":
                anchors[0].position = hit.transform.position;
                break;
            
            case "TL":
                anchors[1].position = hit.transform.position;
                break;
            
            case "BL":
                anchors[2].position = hit.transform.position;
                break;
            
            case "BR":
                anchors[3].position = hit.transform.position;
                break;
        }
    }
}

private void Update()
{
    if (Input.GetKeyDown(KeyCode.Space))
        RayOut();
}

The point where the white line intersects the floor is the expected point that the anchor should be, but the three arrows are where it actually is.

Screenshot

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I figured out the reason, I was using transform.position, when in reality it is supposed to be point. (Credit to ps2goat for also finding it).

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda