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

Scripting for Cube Transformations Help?

Discussion in 'Scripting' started by WhiskeyKiosk, Jul 2, 2016.

  1. WhiskeyKiosk

    WhiskeyKiosk

    Joined:
    Jul 2, 2016
    Posts:
    2
    Hi, guys.

    I'm pretty new to c# scripting for unity, but I have some pretty good Java programming experience, and I'm finding it's carrying over, somewhat, to the engine.

    What I'm trying to do is this:

    1. Rotate a cube at a rate that increases slowly, gets faster, and then slows down and stops

    2. Flatten the cube on the X axis, and extend it along the Z and Y axis at the same rate the cube should be rotating.

    My first image is a concept/mock-up of what I'm trying to do, and some possible, common functions I could use to achieve the rate of rotation/flattening/expanding. My second image is what I want to happen.

    Does anyone have any suggestions, because I'm not quite sure where to start...

     
    Last edited: Jul 2, 2016
  2. Henning_Justare

    Henning_Justare

    Joined:
    Nov 10, 2014
    Posts:
    21
  3. WhiskeyKiosk

    WhiskeyKiosk

    Joined:
    Jul 2, 2016
    Posts:
    2
    Hey, cool! Thanks, man!
    Also, how exactly would I get the xyz dimensions of an already existing cube, by the way?
     
  4. jimroberts

    jimroberts

    Joined:
    Sep 4, 2014
    Posts:
    560
    If your mesh is a cube you could use Mesh.bounds. Alternatively you could use Collider.bounds if your cube has a BoxCollider.