Draggable Objects

I want students to bee able to move items in a shared cospaces project without allowing complete editing. How do I do that? Is there a way to add a button to an object so it can bee dragged? e.g. If they hear a direction like " The gorilla wants to sit in between the tree and the flowers" – right now, when I share the project, they are unable to move the gorilla. Which coding snippet do I use for this? Is there a button that has a ‘draggable’ script attached? Thanks for your help.

Hi @smartears,

This is a common query, and if you search the forum for “draggable” you will find plenty of posts about it.

Here’s one from last week: Size of objects

Geoff @ TechLeap

Thanks Geoff. I went through all the examples - most of them use JavaScript. However, I don’t know JavaScript. I couldn’t really find any coblock to achieve this.
All the students use iPads — does the draggability work on an iPad or only on the desktop?
Finally, I saw a suggestion to attach to the camera - I will try that and see.

You’re correct - this isn’t available in CoBlocks yet. This could be an interesting feature for CoBlocks though, probably using a similar user interface as Attach - what do you think, @Stefan, @Coralie ?

Yes, the draggable interface works for touchscreens; but Scripting isn’t available on iPad (as far as I’m aware).

Geoff @ TechLeap

This example uses only CoBlocks and may be used to achieve your task:

Thanks Nikolay – I tried out the example you posted. However, I’m unable to drag the girl with my mouse or with my keys or with touch on the iPad. It registers that it has been clicked, but then, nothing happens. I also tried clicking on the girl and then clicking elsewhere to see if she would move – but no luck. I will simply have to find another way to add interactivity to the cospaces environment in the play mode. Thanks anyway, and I do hope this process can become easier with additional new features in cospaces.

Ok – So I took the script for the cuboid example and simply substituted the getItem ID for the ID of the character I wanted to make draggable. It worked!!! Yeah!!! I think I was intimidated by the javascript, till I copied and pasted the code in the example and substituted the itemID. Thanks everyone for such prompt responses!!!


Well done!! Yes, Javascript can be a little intimidating, but you’ve obviously got the right “give it a go” attitude that I try to nurture in my students (and teachers), and I’m sure this will rub off on your students too! :grinning:

Geoff @ Techleap

PS: if one of these posts solved your issue, please mark as the solution - this will help others! :grinning:

Hi team,

Here is a space I made up today showing how you can do this with CoBlocks.

Thanks for this @iaincb - it’s good to have multiple approaches to solving problems.

The demo you’ve made is cool - one thing to note when attaching UI elements to the camera is that if they are too far in front of the camera, they will disappear into other objects. One way to resolve this is to shrink the item and bring it closer to the camera.

As an aside, there’s some unusual behaviour on your CoSpace when the attached item enters the ground - the camera gets thrown out of the ground and up into the air! (similar to other Physics clashes)

Geoff @ TechLeap