Add physics to an item in Javascript

Hi, I am using CoSpaces with my class to reinforce and extend their JS skills after learning web development. Is there a way for them to add physics to items in the code instead of click each object manually?


1 Like

Hi @Andrew_Worsnop!

Physics related properties of item can be accessed via item.physics property.

// This is how you can add specific item to physics.
let item = Scene.getItem("Cuboid") as Cuboid;
item.physics.enabled = true

Also there is a global Physics object, which allows add and remove to physics all items at ones.

1 Like

Thanks Ilya! That helps a lot!