Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

235
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!