Home | SCI Documentation | SCI Tutorials | SCI Tools | SCI Wiki | Community

Chapter 5 - Allowing Actors to Walk Through/Over Views/Props

You naturally won't want all the views and props in your game to be obstacles. This being the case, you'll want to allow actors to walk over and through them.

Getting Started

Add Key

If you haven't already done so, open your game in the resource explorer and select "Resource"->"Add Sample"->"View"->"Key" from the menu.

Save it to your game as view.400.

Rm001 Script

You can obviously use this in any script, but for demonstration purposes, open up the game's "rm001.sc" script.

We will now set up the prop.

Scroll down to the end of the script and add the following lines of code:

Code:
(instance aKey of Act
  (properties
    y 160

    x 160
    view 400
  )
)

This simply creates a prop at (160,160) with view.400.

Game Instance

Next, go to the game's instance, then scroll down to the bottom of the init method.

Set up the actor with the following lines of code:

Code:
(aKey:
  init()
)

This simply initializes the prop.

The prop is now fully set up, but if an actor tries to walk over or through it, it will bump into it and be stopped. To allow actors to walk through views and props is simply a matter of calling one simple method.

Adjust the key's initialization to the following:

Code:
(aKey:
  init()
  ignoreActors()
)

By adding a call to the ignoreActors() method, actors will now be able to walk through it.

The only catch is that the views will not actually be walking over it, only through it. If it is high, then actors will still be "behind" it due to it's priority. This can be adjusted with one more simple method call.

Adjust the key's initialization to the following:

Code:
(aKey:
  init()
  ignoreActors()
  setPri(0)
)

By adding a call to the setPri() method, the view will now be a background object which actors will always be on top of.

Compile and run and you'll see it all in action!

That sums it up!

< Previous: Chapter 4 - Moving Actors and Triggering Events Next: Chapter 6 - Checking a Door's State >
 

by helping to defray some of the costs of hosting this site. If it has been of help to you, please consider contributing to help keep it online.
Thank you.
pixe
Top

© 2013 to present The Sierra Help Pages. All rights reserved. All Sierra games, artwork and music © Sierra.