Why is My Slerp The Derp?

So, I’m attempting to get the object to turn around 180 degrees. I’ve checked the doc and looked through the previous answers.

From those I’ve put together this:

    public void TurnAround()
    {
        gameObject.transform.rotation = Quaternion.Slerp
            (
                gameObject.transform.rotation, 
                Quaternion.LookRotation(-transform.forward), 
                3.0f * Time.deltaTime
            );
    }

It doesn’t appear to function, at all - not even the slightest rotation…

What am I doing wrong?

Update 11/13/16:
Okay, so here’s how they’re rotating normally,

        transform.rotation = Quaternion.Lerp
            (transform.rotation, Quaternion.Euler
                (m_CurrentRotation + transform.forward), Time.deltaTime);

To me it literally looks like the same logic with a faster speed and different angle but obviously…

Is your goal to have this happen progressively, over time? Where are you calling this and how often?

@DoubleD17 Sorry, I was having a grump day... I updated the example, was able to compare highscore with it. Hopefully the fixed example works for you.

1 Answer

1

Couple of things, Just know I am not master of Stuff like this. I’m only like 2 weeks old to Unity

But I do believe that GameObjects can’t use .transform.rotation

Because isnt it
public transform Object
or
public GameObject Object

BUUUUUUT Don’t give up quite yet, In all of my codes that have to do with Rotation (Thanks Brackeys)

I didn’t use transform.rotation as you did in Line 5,
I used transform.rotate, So try this

 public void TurnAround()
     {
           transform.Rotate (new Vector3 (x, y, z) * Time.deltaTime);
         // Change the x y or z to you're desired way.
        // Hope this helps!
     }

.