+3 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?

asked Jan 4, 2019 in Engine by blum-o-matic (27 points)

1 Answer

+3 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 ;-)

answered Jan 4, 2019 by blum-o-matic (27 points)
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.