Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

778
Vistas
Unity 3D - Moving an Object around a circle circumference facing forward

I am using Unity3D to move the player around the circumference of a large circle facing inwards towards the centre at all times.

The following code works by using transform.forward

  // Rotate the forward vector towards the target direction
    Vector3 newDirection = Vector3.RotateTowards(transform.forward, targetDirection, singleStep, 0.0f);

and then I move the player sideways by using

characterController.Move(horizontalSpeed * transform.right * Time.deltaTime);

I have been stuck on how to get the player to move around the circumference but facing forward with the left of the player facing the centre of the circle. My code is as follows

   void Start()
    {
        characterController = GetComponent<CharacterController>();

    }

    void Update()
    {


        // Determine which direction to rotate towards
        Vector3 targetDirection = GameObject.Find("Platforms").transform.position - transform.position;

        // The step size is equal to speed times frame time.
        float singleStep = 1 * Time.deltaTime;

        // Rotate the forward vector towards the target direction by one step
        Vector3 newDirection = Vector3.RotateTowards(transform.forward, targetDirection, singleStep, 0.0f);

        // Draw a ray pointing at our target in
        Debug.DrawRay(transform.position, newDirection*50, Color.red);

        // Calculate a rotation a step closer to the target and applies rotation to this object
        transform.rotation = Quaternion.LookRotation(newDirection);

        CheckIfOnGround();

        characterController.Move(velocity * Time.deltaTime);

    }

   
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Replace transform.forward to transform.left

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda