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. Dismiss Notice

Rotating a square by its two opposed corners

Discussion in 'Animation' started by pixelfixation, Jan 26, 2022.

  1. pixelfixation

    pixelfixation

    Joined:
    Feb 7, 2014
    Posts:
    29
    I am making a game jam game that involves flipping floor tiles to progress through the game. The tiles are square and should be able to be flipped in 3 directions. North to South (180 degree x axis rotation) west to east (180 degree z axis rotation) and diagonally corner to corner....

    But how do I create that motion?

    I tried playing with the values of X, Y and Z, but the best I can get is a sloppy motion that only ends it the right place. What I would really like to do is be able to animate along a custom axis that runs corner to corner, but I can find any way to do that.

    I tried creating an empty object, rotating it 45 degrees and childing the tile object to it in code then making an animation rotating the 45 degree rotated empty. This sort of works but not really feels extremely hacky.

    How do I accomplish this motion?
     

    Attached Files:

  2. unity_2cdeity

    unity_2cdeity

    Joined:
    Dec 19, 2020
    Posts:
    17
    Sloppy as in the first 45 is different from the first or unnatural? Velocity doesnt normally just snap an object into place.
    By code you would need to change its time,delta, by animation you need to change its speed by just changing its position more between equal parts.