Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Moving Cube by scripting sphere position

Discussion in 'Physics' started by benjaminver89, Oct 16, 2015.

  1. benjaminver89

    benjaminver89

    Joined:
    May 14, 2015
    Posts:
    30
    What i want is to move a cube by knowing position of three corner.

    I tried hierarchy (sphere inside cube ), but cube is ejected.
    I also try to put sphere under cube, but cube slips....
     
  2. DDelapena

    DDelapena

    Joined:
    May 3, 2013
    Posts:
    6
    Hello,

    I'm having a hard time understanding what you want. You know 3 of the 8 corner point positions of a cube, and you want to move the the rest with it? Which corners do you know already? lets say you know bot1 corner, and bot2 corner, and bot3 corner. You can potentially find the length between corner1, and corner2. (A) And the same with corner2 and 3. (B)
    We can't assume this cube is upward in Y(could be rotated?), so Use the cross product to get the perpendicular angle of the segment of corner1, and corner2. and use A as the length to add for the next point for top1 point. use this method to get the rest.

    have i mis-read what you need? Confused on how this applies to games.

    Perhaps you mean, you want to animate a cube to 3 vector positions. In this case, use LERP or SLERP, over time, or get the vector direction from your starting position, to point1, then from point1, to point2, etc. Use transform.LookAt() to get the object to look in the vector direction as well.
     
  3. benjaminver89

    benjaminver89

    Joined:
    May 14, 2015
    Posts:
    30
    Hello DDelapena,
    In fact, i have three 3d points and i wanna match them with a cube.
    I hoped that it will be possible thanks to physics and cube parameter.
    But yes, i can compute them and apply rotation and translation.
    It's not really for game yet, just for visual testing.