Search Unity

Force full instant rotation

Discussion in 'Scripting' started by Disolution, Sep 16, 2014.

  1. Disolution

    Disolution

    Joined:
    Feb 24, 2014
    Posts:
    71
    Good Morning,

    Would like to know if there is a way to actually rotate a object without instantly like assigning directly the object rotation without it turning from x angle till y angle, i've been searching for this information for quite a while and all i stumble upon is pretty much Quartetions and eulerAngles that dont affect it as i want it since im doing a 2d platformer and inverting the scale on it to flip will mess my box colliders being that the inverting method is the one im using currently :\

    Would really appreciate some help on this matter if possible

    PS: need it to be in an instant like 90º angle to -90º angle without going from 90 to -90 by "uncrementing", not sure if im being explicit with it sorry

    Best Regards
     
  2. MrPriest

    MrPriest

    Joined:
    Mar 17, 2014
    Posts:
    202
    Do you mean like a mirror? There's an option to mirror the object.
     
  3. Disolution

    Disolution

    Joined:
    Feb 24, 2014
    Posts:
    71
    Well not sure, never "seen" that mirror method, as it still sounds to me like its making the x scale to -x scale ending up "mirroring" it
     
  4. MrPriest

    MrPriest

    Joined:
    Mar 17, 2014
    Posts:
    202
    Well, I'd love to give you an example, but my code is not with me.
    I also can not seem to find it on the web, but I am quite sure there was an option like that... I'll post back if I find it.
     
  5. BmxGrilled

    BmxGrilled

    Joined:
    Jan 27, 2014
    Posts:
    239
    Double sided shader and the invert method?! Might work maybe?
    :)
     
  6. Disolution

    Disolution

    Joined:
    Feb 24, 2014
    Posts:
    71
    If u could give me an example of it so i can understand what you talking about xD
     
  7. MrPriest

    MrPriest

    Joined:
    Mar 17, 2014
    Posts:
    202
    I am also interested, I don't know what the Double Sided Shader means. I did not play around with shaders, but isn't it a visual thing?

    As for you Disolution, I think there is a "mirrored" option in the animator, so I guess I used that with the invert method, so I don't think I can be much help there.
     
  8. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Of course. Just assign the rotation you want. For example:

    Code (CSharp):
    1. transform.rotation = Quaternion.Euler(0, 0, 90);
    This sets the rotation to 90 degrees directly, without it "turning" (interpolating) in between. Indeed, if you want an object to rotate smoothly from one angle to another, you have to do a bit more work. Instantly switching to a new rotation is the easy thing.

    Now hang on. You're going from one topic to another in one massive run-on sentence. Let's break it down:

    1. Claim: Quaternions and EulerAngles don't work for a 2D platformer. This is false. They are relevant to both 2D and 3D games in Unity.

    2. Claim: flipping the object by inverting the scale messes things up for you. OK, then don't do that. You were asking above about rotation, not flipping; these are completely different things.
     
  9. Disolution

    Disolution

    Joined:
    Feb 24, 2014
    Posts:
    71
    Sorry commas make a whole diference on a sentence and i tend to forget them xD And the flipping was done due to not bein gable to make the player rotate directly (marked as answers on unity answers thus i ended up using it until i managed to work out throught rotation)