For my student project, I need to know how to do this purely using either javascript or blockly. I got the idea from my classmate but his code doesn’t either. Thanks for all helps appreciated!
I am very new to CoSpaces, but I tried the following to do what you need.
Setup
I placed the boy character in the view of the camera. I added a cuboid at the same position as the camera. Finally, I attached the boy to the cuboid; this way, wherever the cuboid goes, the boy will follow. This is what it looks like in creation mode:
Code
The idea is to make the cuboid to follow the camera. Since I could not find a way to attach the character to the camera, I decided to have the cuboid follow the camera using the update block.
Notice that I first make sure the cuboid and the camera start at the same location. Then I set the location of the cuboid to the same location as the camera with each update call.
When you move with the WASD keys, the boy follows:
Problem
Even though the boys seems to follow the camera with the WASD keys, everything falls apart when you try to turn the camera. There does not seem to be a way in CoSpaces to have one object to adopt the direction of another. There is a “direction of” block, but I do not see where to use it.
Cheers
Please ignore my previous post.
It turns out that you can actually attach a character to the camera using the object tree.
Here are the info (see Stefan’s post on May 3rd)