My First Test: Animated Robot

This is my first test using PlayCanvas, and I’m more than happy with how PC works so far. This is a low-poly character with a long test animation on it. The character is for a treasure hunt game I’m working on “behind the scenes.” The stick in his hand is going to be a wand/spear, but for now it’s just a test for parenting an object to a bone. (Edit: I changed the stick to a wand.) Had some trouble with that at first, but now it seems to be working (the spear kept rotating the wrong way). I hope the PlayCanvas people don’t mind that I stuck the robot on top of their Starter Kit cube. I’ll pay for any damage the robot does to it… :sweat:
https://secrettreasurepath.com/StarterKitRobot/index.html
Please ignore that animation; it was meant to be edited, divided up and copied into smaller animations in Blender, so it looks kind of strange for now.

1 Like

I revised the robot somewhat and added a little bit of interactivity: Hold P key for a wand-casting movement, and Hold O for a walk cycle. It’s not much, but I’m learning and testing the scripting part of this program.

Cool—I like it! You might try speeding up the blend time between animations—the transitions seem a little unnatural right now (e.g. going from walking to standing still). In order to get it to look really nice you might need to be able to specify a curve for the transition, though (e.g. ‘sin’, ‘exponential’, ‘overshoot’, etc.)… Not sure if that’s possible to do at the moment.

1 Like

Thanks! Yes, the robot is a little “rusty” at the moment. Right now I’m in the process of changing a lot of things in the scene, including the cubemap, lighting, adding particles to the wand, etc., so I haven’t given thought to blending for a while. This was my first-ever character creation, way back in 2006, when I was learning Blender. That explains the low-poly look and the reason I decided to call it a robot, lol.

I just uploaded the latest updates. Took me a while to figure out how to attach/script the particles to the wand, because the sphere at the end of the wand was parented to the wand and the wand parented to the robot’s hand bone in Blender. I also sped up the blendTime–and you’re right; it looks much better. I’m familiar with lerping movement, but know very little about curves, so I’ll have to look that up.

I took away the PC cube and replaced it with a crate, added some flowers (because robots can be programmed to enjoy beauty), and enabled the camera movements. Thanks again for the suggestions.

Still not much to see here, but I added a few things: When the camera rotation stops, you can click on the red and yellow cubes to rotate the robot one way or the other. That was my first attempt at raycast-picking, and I was surprised that it worked. O and P keys still activate walking and wand-casting–but the wand still doesn’t shoot anything; that’ll be my next experiment. I was testing different things, including the use of timed and randomized rotation of the icosphere. That particular script also calls the red and yellow rays from the very two-dimensional ship to the rock. When the red ray is “shot,” the rock flashes, That was a rough experiment using two separate entities instead of two materials or textures on a single entity (which is what I’m going to change it to eventually). You’ll notice a bad “jank” the first time you press the P key. That’s caused by switching from one light to another, something I’m going to change soon.

Oh, the cone is parent to the camera. That’s where the camera rotation originates from. I got the camera to stop rotating by adding 0.6 to a global variable in the update function (matching a 0.6 rotation on the y axis). When the variable reaches 360–a full circle–it switches off a boolean variable, shifts the y axis rotation to 0 and disables the script. I’m not sure if that’s a kosher way to do it, but it worked, Eventually this is going to turn into a small game, and the cone won’t be there anymore…

A few more changes: I added a missile to the wand-casting, borrowed an explosion and animated texture script from the fireball tutorial, did my first in-game text, removed some unnecessary entities, tweaked some scripts, and added one sound effect and some music. I still don’t have anything for the robot to shoot at, but that’ll be my next project.

](https://secrettreasurepath.com/StarterKitRobot/index.html)

Here’s an update of the space robot thingy, and I turned it into a game/birthday greeting card for a friend of mine (you’ll see the greeting at the end). Whether the player wins or loses, the same greeting will come up. Eventually I’ll turn this into a regular game. It’s not finished yet–no sound effects (except for one)–and it’s in dire need of cleanup and optimization. There were a lot of workarounds and experiments in here, with leftover scripts and entities and unused materials/textures.

I’m planning to change the music. It’s my own composition, and I’ve heard it 8000 times…

Because there are no in-game instructions as of yet, I’ll type them here:

INSTRUCTIONS
1. When the robot collapses after the intro segment, press the K key to revive him and start the game.

2. You are trying to destroy 12 spaceships, and there are two weapons at your disposal: a wand (press and hold the P key) and a rotating force field (available only when the blue button is visible–click and hold the button until the force field expands and contracts. It’s programmed to destroy each ship only 1 out of 3 times, randomly, and it automatically disappears whenever you release the mouse button.). Debris from wand missiles and destroyed ships can also destroy the ships, so fire the wand as much as you can, even if you miss.

3. To try to avoid the ships’ deadly rays, press and hold the O key, causing the robot to collapse out of harm’s way. If you don’t time it right, the robot will still get zapped.

4… Click and hold the two square buttons to rotate and aim the robot. Note: the robot can rotate while in the collapsed position.

5. The click-counter under the platform tells you how much life is left in the robot’s batteries. The ships’ rays, when they hit the robot for just the right amount of time–and in the right way–are what sap the batteries’ strength.

6. You will notice cylinders flying out of the destroyed ships and lining up along one side of the screen. You will discover their significance only at the end of the game.

(https://www.secrettreasurepath.com/SpaceCake/index.html)

I just noticed that the “aspect ratio” of the view of the game is wrong on some other computers, and it’s cutting out part of the scenes, so I’ll have to fix that tonight. It’s fine on my computer, but not on some others that I tested it on–not sure why that is.