To put an object in its original direction

How can I put an object in its original direction, whether “physics” is activated or not?

Does anyone have this answer? My students want to do this also.


we had the reset-orientation functionality in previous versions of CoSpaces and will re-introduce it with future updates. Until then, I recommend making use of item snapping so that the items you rotate can be placed back to their original rotation with ease.

Hi, OK but how can I do when “physics” is activated?

Hi Daniel,

to reset the direction & position of an item during play mode, you can store its initial values at begin of the scene and call the methods .setDirection or .setPosition. To apply these changes on an item with physics, you have to remove the item from its physics simulation, apply the changes, and then add it back to the physics simulation. Below is an example:

Show JavaScript example

//Assuming the item 'man' is a physics item at start
let man = Scene.getItem("man") as GameItem;

//Store direction and position at start
let originalDirection: Vector3 = man.getAxisY()
let originalPosition: Vector3 = man.getPosition();

//Applies velocity on physics item
man.setVelocity(0, 5, 0);

//When man is clicked, remove physics simulation, apply changes, then add back to physics
man.onActivate(() => {
    man.setPosition(originalPosition.x, originalPosition.y, originalPosition.z);
    man.setDirection(originalDirection.x, originalDirection.y, originalDirection.z);


The methods setVelocity, removePhysicsBody and addToPhysics are still internal and will be treated as unavailable in your editor, but they still work. We’ll adjust their visibility for the coding editor soon.

Hi Stefan, Thank you. That’s what I was trying to do. In my project your solution works, but sometimes the physics mode does not work. I have to look for why.
Our goal is to make an arcade game with a 3D printed cannon, a laser, a joystick, a button, targets, servomotors, sensors, a programmable electronic card, … We do not manage to simulate the cannon mechanism for the moment.
Here is the current state of our project with CoSpaces: