How to orient an object permanently to the south? Unity iOS/Android 3.5.7

Hi there.

I have this problem, I’ve tried some things, but nothing seems to work, I need an object oriented specifically to the south permanently, but I can’t seem to achieve it.

Some ideas please?

Cheers and thanks in advance.

Hi there.

Upping the thread, I can’t find a way to solve this.

Cheers and thanks.

Perhaps this will help?

http://lmgtfy.com/?q=unity+compass&l=1

Let me thank you the sarcasm, but no, that does not help at all.

I know how to use the compass, and probably the question is a bit silly because probably the solution is a simple math function that my brain cannot develop for some strange reason.

I know how to orient an object with the compass and how to get a compass value, the question is how to make that object fixed pointing to south.

Te thing is that I’m not being able to deal with a probably simple algorythm that for some reason is locked in my mind, and I cannot solve.

But thanks for the try :slight_smile:

Cheers.

Forgive me, I’ve been wanting to use that - ;).

http://docs.unity3d.com/Documentation/ScriptReference/Compass-trueHeading.html

Couldnt you just use this but rotate 180 degrees for south?
From Doc:

// Orient an object to point northward.
transform.rotation = Quaternion.Euler(0, -Input.compass.trueHeading, 0);

So:

	transform.rotation = Quaternion.Euler(0, -Input.compass.trueHeading + 180, 0);

Or am I still misunderstanding?

The problem is that TrueHeading is a variable value, so it will give the actual heading value, if you are heading to west you have a value, if you add 180 degrees, you will have the east value, but if you change your orientation to northwest you will have southeast.

Think that the south value is 270 in true heading for example, well, if I change my orientation I need the object to be south oriented permanently, no matter where do I point to, it’s like the fixed component of a compass that it’s always pointing to north.

The thing is that the scene is not always oriented to the same point when you start the app, and it depends on your position and it depends in the device also, so I want to correct that object orientation always, so if the scene get’s loaded with a different orientation I will have that object correctly oriented always.

I think it has to be a simple mathematic function, but as i said, my brain is locked with this :stuck_out_tongue:

BTW, don’t worry about the sarcasm, If I understand that someone is asking for some basic documentation related thing I would answer something similar hehe, but I’ve digged a lot into goole, answers and forums and I’m not being able to find a useful answer.

Cheers.

Maybe I’ve understood wrong the true heading… because from you answer i can read: “// Orient an object to point northward.”

But I think it’s a variable value, I’ll re-check this.

Thanks and cheers.

The doc makes it sound like trueHeading (or magneticHeading if you dont want to enable location tracking) will have a live value of your heading relative to North. So it will change based on which direction you are facing. So if you set an object’s orientation to that value, it will always face North no matter which direction you turn to.

I would suggest you test on a device and see what values are returned to be certain.

Good luck.