Change collision object/shape values from script



I wonder if it is possible to access and modify values like dimension and position for shape objects through code. I need to set those dynamically from script because dimensions and position depend on player’s input. Only other solution I can think of is making a factory and prototype object for all possibilities and spawn one that corresponds to player input. But there are too many of them and it would affect performance dramatically.

Also, I have one more question that may be related to this. Is it possible to add component to game object from script? For example, I want to add that collision object when player does some action, instead of adding it manually.

Thanks in advance


You cannot set the shapes or dimensions of the collision components at runtime.

And, currently, you cannot change the scale of the physics object by scaling the game object either. We have an issue for that:

There is a workaround, and that is that you can set the scale when creating the game object via a game object factory.

ANd, no yo cannot add components at runtime. You can enable/disable components though:


Thanks very much for reply. I will try to make it work with that workaround.