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

250
Vistas
How to Lerp between 2 Z-Axis points in Unity, and Scale a Component accordingly

I'm working with Unity 3 and my total level size will be just a quadrilateral area with a wall on each side. Within this will be two additional walls that create an enclosure that restricts the player to a portion of the level that gradually expands.

I call these two walls ZBoundary and XBoundary, and so far for a prototype have mapped their movement to some keyboard keys. What I want to do is when one moves, the other grows in length so they are always joined at a perpendicular angle, so I want to be able to linearly interpolate between, for example, the ZBoundary's Z-coordinate and the Z-coordinate of the Xboundary so that they always meet and create a join. This creates a problem as well, because I don't know how to change the size of a GameComponent programmatically, and keep getting errors.

I know Vector3.lerp may help but I'm drowning in transforms and different scales and so would appreciate the help.

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

0

I'm halfway there by now getting the XBoundary to adjust its position in order to always lock to the ZBoundary at 90degrees

        ZBoundaryRef.transform.Translate((-1 * distancePerZMovement), 0, 0, Space.World);
        // using Space.World so transforms are using the global coordinate system!

        // what I've done here is say, move the XBoundary Z-CoOrd so that it aligns with the ZBoundary Z-CoOrd.
        // the origin of an object is at it's centre point so we need to take this in to account to ensure they join at the corners, not in a Tshape!
        float difference = (ZBoundaryRef.transform.position.x - XBoundaryRef.transform.position.x);
        float adjustment = difference + (ZBoundaryRef.transform.localScale.x/2);
        XBoundaryRef.transform.Translate(adjustment,0,0,Space.World);
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