News Box
WELCOME TO MLNO!!! ... ENJOY YOUR TIME HERE! ... WHILE YOU ARE HERE, CHECK OUT OUR RPGS!
My LEGO Nexus Organization
January 31, 2026, 11:26:12 am
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Welcome to My Lego Nexus Organization! A LEGO Universe, LEGO and My LEGO Network Fan Site! The LEGO Company does not sponsor, authorize, or endorse this site.-- New? Check out the welcome forum and get started! Got questions? PM Blade, or one of the other active members of the staff.
 
  Home   Forum   Help Arcade Gallery Rules Staff List Login Register Chat  

BrashSmashes Behaviors Tutorial #2

Pages: [1]   Go Down
  Print  
Author Topic: BrashSmashes Behaviors Tutorial #2  (Read 219 times)
0 Members and 94 Guests are viewing this topic.
MsRowdyRedhead
Sage Mentor......... (renowned for profound wisdom)
A - MLNO Featured Admin of '08
Exciting Poster
*

MLNO Reputation 100
Offline Offline

Gender: Female
Awards:
Team: No Team
Purpose: Harmony
Posts: 15328


The forum can't be the same without our friends.


WWW
Badges: (View All)
Tenth Year Anniversary Ninth Year Anniversary Eighth Year Anniversary
« on: May 12, 2011, 09:24:34 pm »

This is the second behavior tutorial, focused on communication between models, which can be used to make more interesting scenes. If you are new to custom behaviors, you may want to read part 1 of this series first.

In this tutorial, we will build a pirate target practice range. The active object will be a canon and the reacting objects will be a pile of crates. Here's the scene with the models placed and no behaviors yet defined:

First of all, we define the behavior for the canon. This is pretty straight forward, with a series of action blocks triggered from an Interact start block:


Here's a close-up of the behavior chain with explanations:


    * Interact means behavior is triggered by user pressing Shift when near the canon
    * Sound "electricity" for the fuse burning
    * Wait "1" creates a short pause for the fuse sound to finish
    * Silent Chat "canon fire" sends a message to the crates
    * Sound "explosion" for the canon firing
    * Move Backwards for the first part of the recoil
    * Move Forwards for the second part of the recoil
    * Reset is always a good idea to finish a series of action blocks


It's worth a digression here to note the importance of the Reset block. If you have a set of actions which changes the state of a model, particularly movements or rotations, it's best to put a Reset at the end. Sometimes the behavior timing will get out of sync and the Reset will put things back into the original state.

Now let's move over to a crate and create the behavior for all of them. We will edit the behavior on one crate, save it, and then just copy it to the other crates. Here's the two behavior chains, both beginning with On Chat start blocks.


Here's a close-up of the two behavior chains with explanations:

The first chain is triggered by the canon firing:

    * On Chat "canon fire" starts in response to the canon behavior Silent Chat action
    * Wait "1" to allow time for the canon ball to fly
    * Sound "brick smash" for effect
    * Smash to explode the model
    * Wait "10" to leave things for a bit
    * Reset to put the crate back into its original state


The second chain is useful while debugging: it allows you to type "reset" in the chat window to put things back. It's always handy to have this in case the behaviors do something different than you expected and you want to quickly put things back to normal while testing. If you have a reset action on all your models, you can always put everything back with a simple chat message.

It's worth spending time up front to get the behavior of the canon and crate working, before adding the behavior to the other crates. Once things are working the way we want, we'll save the create behavior for use with the others. Here I've tried to show how we can drag the named behavior into our backpack behaviors tab:


And then we move to the other crates and drag the behavior from our backpack onto the square with the plus sign to apply that behavior to them:


Finally, we can type "reset" in local chat to restore the crates without waiting for the normal timer:


I created a short YouTube video of the scene in action.


Silent Chat, which at first seems so pointless, is the magic which allows models to interact with each other. There are other methods as well. For example, if models are moving you can trigger a behavior another model runs into the model with the On Impact start block.

The other important thing here is Reset. When your behaviors start getting more complex, you will start running into issues with the timings, particularly with On Impact. The more you can use Reset to restore the original state, the more reliable the resulting behaviors will be. If you want the behavior to end in a changed state, you can't use a Reset block, but it's still handy to have a separate behavior chain starting with On Chat "reset" and the Reset action to restore things.
Report Spam   Logged



The dream is free.. the work to achieve it is sold separately.
OOC: An OOC expression of horror would confirm your humanity nicely. Wink
MLNO.  The only forum I know where expressions like the one above are commonplace. Tongue
Everyone is frustrating in their own special way.
Quote
"Right is right, even if everyone is against it. Wrong is wrong, even if everyone is for it." ♥
"If you're not havin a good day, change your mind!!"
Pages: [1]   Go Up
  Print  
 
Jump to:  

LEGO® is a trademark of the LEGO Group, which does not sponsor, authorize or endorse this site.
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum

Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy
Page created in 0.055 seconds with 14 queries.