Skip to main content

Actors

You can read or modify actors in various ways using a script. There are a few different ways to get a variable representing an actor in a script:

  • my - a special variable that always represents the current actor
  • triggeringActor in onMessage
  • castle.createActor("Wall", 0, 0)
  • castle.closestActorWithTag("tag")
  • castle.actorsWithTag("tag")

Each of these returns an actor type. Here's an example of setting some properties on different actors:

This is the Golf Course kit with a script added to the "Ball" blueprint.

As you can see, the Ball blueprint and the Ground closest to it are both rotated.

Properties

Any of the properties that you can get or set from rules can also be used from scripts. Here's an example that changes the Slingshot speed and the Gravity of the golf ball. Try shooting the golf ball:

This is the Golf Course kit with a script added to the "Ball" blueprint.

When you start typing in the editor, it will show you a list of properties that you can use. For example, if you start typing my.layout. it'll show you that you can use x, y, widthScale, heightScale, rotation, visible.

Try playing around with changing other properties!

You can find a list of all properties available on actors here