How do you code an item to attach as a child to the camera? Eg, I have a student that wants to ‘hold’ a key so that when they bump into the door it will open.
Hi @iaincb,
The easiest way to do that is to use the add
and detach
blocks in CoBlocks. They’re located in the Items category. Below is an example space. You can press the remix button to copy this space and take a look inside the code . The second scene also demonstrates how to achieve this behavior in script.
Hi Stefan,
Thanks for your answer! I found a second way that works more how the student wanted it to. In your demo the key is directly and immediately in front of the camera.
What I did was to create an invisible cuboid and make that a child of the camera. The key then attaches to the cuboid rather than the camera itself. This lets the creator place the cuboid so it looks to be in a more natural holding position.
Hi @iaincb,
That’s a really clever idea to ensure the correct holding position! Looking forward to the projects that will be done with it
We’ve gone one better. Now we have a hand model from Google Poly (this is a great addition BTW!), so that the key can be ‘held’
We thought it would be great if there was a CoSpaces animated hand that would have open and closed animations…
This makes it feel much more natural when using.
Hi there
Sure can! Here is the link to the space. https://cospac.es/iWX9
It is also now in the gallery.
regards,
Iain
Hello, can you briefly explain, show me how you placed the hand so that it would not collide with the floor?
thx Gerrit