Create a clone and have the clone appear in a random location on the CoSpace grid

My code is working as far as creating a clone for the lion. The problem is the clone is appearing on top of the original lion.

Here’s some examples:

Thank you for the examples however they really didn’t answer my question. All the examples posted are very complicated.

I do have a suggestion for the site however, it would be very helpful to educators for CoSpaces to make available examples of basic code that teachers, students, and parents can use to help them on their coding journey. Maybe make a new category under the gallery called ‘Examples’.

Just a thought.

P.S. I tried to find the answer in the examples and tweak my space. Now it doesn’t work at all. Lesson learned.

@TechWarriors Here is a working version with explanation, that being said there is alot of documentation available on coBlocks, in the forum and their youtube.
Then when you want to make something unique its best to write it down step by step what you want to do;
Make copy of object.
Change its location to a random one.

Then you just go down the list:
Make a copy you were already able to do,
Change location, you could do on a normal object, just not the clone,
And make a random number, you can also do, given there is a coBlock specifically made to do that.
So the problem you encountered was that you did not know how to directly reference a copy (so as to change its location).

Then looking at the examples provided by @techleapnz you could look up how this specific action is done, which is by storing the copy inside a variable, then referencing that variable to change the position.

Hope this helps!

1 Like

“…did not know how to directly reference a copy (so as to change its location)”.

You are absolutely right…that was my problem. Thank you so much for the explanation as it helped a lot!

@TechWarriors, it’s always difficult to know, from afar, where a fellow teacher is on their coding journey - thanks for clarifying. I encourage you to persevere with coding examples, stepping through line-by-line to work out what’s going on in the code - this is a common way for students and developers to learn. And yes, mistakes do happen, and yes it can be frustrating, but this forum can help.

I have often encouraged CoSpaces to provide a curriculum and/or lessons, but in the absence of such, using this forum and YouTube playlists such as Teacher Resources and Tips & Tricks can be good for finding solutions to coding problems.

You will also find examples and demos to common problems by typing “techleap” into the Search field in the Gallery.

Best of luck!

Geoff @ TechLeap