How to set a position of a object with the value of rotation

Is there a any simple way to set the position of a object with a certain value of rotation degree?
On the tap of Transofom menu of object, we can find the value of position and rotation. After object moves somewhere, I’d like to reset the position of the object to the previous one.
Please advise me how to do! I always have some trouble with positioning.

Hi @HowToCoding,

The best way is to store the position of object in the beginning and then restore it when you need:


You could also create a hidden object on scene and set the position of the object you want to its position:

I create a sample for you. Press “R” to return to original (and stored) camera position and press “T” to jump to new position defined by other hidden camera
Feel free to remix and investigate the code here:

2 Likes

Thanks for your reply. I will follow your direction. By the way is there a way to use a certain command of transform filling the position and rotation degrees directly?

Following your direction, case_A is working but case_B is not working.
Please find my space. Since blue brick wall changed its original position and rotation, it doesn’t go back to initial position. ( To fix this problem, I added some part to the blue brick and made a Green brick group. Then the group is working properly. )

Please, share your space so I could take a look at it.
(here is a tutorial how to do it: How to share a space)

Please take a look at this. ( CoSpaces Edu :: CoSpace 2 )
Thanks,

( Am I sharing the space correctly? )

Currently in your CoSpace the return works. Could you please share non-working example and set “Remix enabled” in sharing options.

Also, you could stop transitions when the space bar is clicked to prevent situations, when the space is clicked when walls are moving

The space I shared last time, it was the non-working space.
Please focus on the position of the Blue wall when space starts very beginning. I call this Position_A. After you move the Blue wall with up/down key, when you press space-bar the Blue wall goes to a certain position ( I call this Position_B) which is not the same position as Positon_A. After this happened, whenever the Space-bar pressed, the Blue wall goes back to Position_B. I guess you think every thing is working properly because of this.
Actually I like to reset the Blue wall to Position_A instead of Position_B which is not intended.
This time, I allowed the space remixed, CoSpaces Edu :: CoSpace 2.
Many thanks,

Hi, the problem is the direction block sets only the direction, not all orientation. For most cases setting position and forward axis is enough, but your case is example, where other two axis may look to not expected direction.
Currently, we cannot completely restore the objects rotation with CoBlocks. It can be done using scripting API:

let obj = Scene.getItem("")
let rotation  = obj.transform.rotation
obj.transform.rotation = rotation

More information about transform namespace can be found here:
https://cospaces.io/api/classes/transform.html#rotation

I hope that helps, if you have more questions, feel free to ask

Thanks a lot for your full support.
I need to study scripting API although it seems to hard to learn.
Cheers,