How to Get a Reference to a Champion

By InstantKafka (Dec 2014)
Copied from ProjectSpark.com

So the latest update comes with two new really cool props: Champion Picker – Full and Champion Picker – Mini. These props contain all the necessary UI and interactions to select a champion to play and then bring it into your world. These props can be found in the Champions tab of the prop gallery. Go ahead and pick the Champion Picker – Full and add it to your world now if you want to follow along with the rest of this tutorial.

These props are fine if you want the champions to just do their thing in your world without any additional logic, but if you’re like me, you want complete control over everything in your level, including the champions.

The first step is to get a reference to the champion after the player selects one. There is a special global object variable called ‘Player’ that TD has kindly provided to us for this purpose. Please note, this is NOT the [player] tile found in the Objects folder of the Kode wheel. This is a specific object variable called ‘Player’ to which the champions apparently assign themselves to when they’re created.

Add a logic cube to your world and add the following line of Kode:

W: [global][object var: Player] D: [display][I’m here to help!][screen center]

NOTE: You probably have to create a new object variable called ‘Player’ yourself. That’s ok. The champions will still use it, even if you created it first.

If you haven’t added the Champion Picker – Full prop to your world, add it now and test the level. The full champion picker UI will appear allowing you to select your favorite champion. Once selected, the new champion will appear in your level and ‘I’m here to help!’ should be displayed in the middle of your screen.

Pretty cool, but how do we know [global][Player] is actually pointing to our champion and not just any old object? Try changing the line to this:

W: [global][object var: Player] D: [display][global][Player][name][plus][newline][plus][global][Player][level][screen center]

The [name] tile is found in the Appearance folder of the Kode wheel and the [level] tile is found in the Champions folder.

When you test the level again, it should display the champion’s name & level in the center of the screen. The [global][Player] variable is indeed pointing to our champion.

Now that we have a reference to the champion in our level, we can do all sorts of interesting things with them. Check or change their properties in Kode, push or add brains to them with our own logic, make them dance, whatever. The key was to get a reference to the champ first. I hope that helped and I’d like to know if anybody has found other interesting things about using the champions in their own levels.

Comments are closed.

Website Powered by WordPress.com.

Up ↑

<span>%d</span> bloggers like this: