Coding a created object

Sorry if this has been answered in a tutorial or on the forum … I have
searched but could not find the answer !

I am working with a class who want to create a “jungle” so they want
to add elephants, etc using code. We added an elephant using the Blockly
“create” block and gave him a name of “Fred”. But we cannot then use
“Fred” in any of the other blocks … for example “transitions” if we
wanted to make him walk around.

Thanks for any help you can give …

Hi focusedu,

Create block (second one in the list) returns new created item. Store that item in a variable (see “Variables” section) and then, when you want to apply a transition to this item, attach this variable block to your transition.

1 Like

Thank you. Worked perfectly ! We have a herd of elephants beginning to appear. For some reason one of them rises in the air when you activate him … I must ask the class why :slight_smile:

Is there any way to do this using CoBlocks?

Hi @Christopher64,

Yes. You can use the create copy of object block, and set a variable to have this block as the value.

For a more advanced version, see the following remixable CoSpace:

Hope that helps! Let me know if you have any further questions about this. If this solves your problem, please mark this post as the Solution.

Many thanks,
Geoff @ TechLeap