+6 votes

I don't understand the orientation in the set_cell_item method:

set_cell_item ( int x, int y, int z, int item, int orientation=0 )

The documentation say:

Optionally, the item’s orientation can be passed.

For example: When i use 0 it is original. If i use 10 it is 180 degree rotated. In the source code of the engine there is p.rot used.

Maybe someone can me explain how to calculate the orientation?

in Engine by (36 points)

1 Answer

+6 votes

It was hiding a bit in the docs but at the end i have found a way (180 degree rotation on y-axis):

 var myQuaternion = Quat(Vector3(0, 1, 0.0), deg2rad(180))
 var cell_item_orientation = Basis(myQuaternion).get_orthogonal_index())
 set_cell_item ( int x, int y, int z, int item, cell_item_orientation )

Code snippet... maybe this helps others. IMHO it should be pointed out in the docs ;-)

by (36 points)

There's an extra brackets in the code.

Line: 2
Col: 74

Check it.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.