Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Getting Object To Move Perpendicular To Velocity

Discussion in 'Physics' started by g4qh4, Nov 14, 2022.

  1. g4qh4

    g4qh4

    Joined:
    Dec 15, 2021
    Posts:
    24
    Hi, I have an object in my scene that is always moving left and right at an equivalent velocity and distance.

    The object's velocity is ~ -0.25 left and ~0.25 right. It moves approx. the same distance left and right.

    I want this object to move perpendicular to its left and right velocity no matter which direction the object is facing. I calculated the cross product of the velocity and upward vector, but since the velocity is left then right, it will move forward a unit and then back a unit....

    How can I get my object to move towards its perpendicular vector?
     
    Last edited: Nov 14, 2022
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,589
    I don't follow. The "facing" is rendering, what does that have to do with physics? Asking to "move" perpendicular to velocity is a contradiction.
     
  3. tjmaul

    tjmaul

    Joined:
    Aug 29, 2018
    Posts:
    468
    There are many vectors that are perpendicular to the left-right vectors you described and they actually form a plane that contains all perpendicular vectors.

    To be a bit more specific to your problem: if your object moves left-right, up is as perpendicular as forward or any combination of the two. Can you explain in more detail what you’re trying to achieve?