Triggering animation

If you feel like you're up to the challenge of building your own Ages in Blender or 3ds Max, this is the place for you!

Triggering animation

Postby ekimmai » Sat Aug 09, 2008 1:33 pm

I've been playing around with alcscript in order to get some animation to be triggered by the mere presence of my avatar in a region. I had thought this would be a simplified version of the clickable region code but can't get my animation to start. Unfortunately my knowledge of alcscript is VERY limited.
Is this achievable with things as they stand in Uru and pyprp? If so could someone PLEASE give me an example piece of code to give me some ideas?

Many thanks!!
Ekimmai
ekimmai
 
Posts: 79
Joined: Mon Apr 14, 2008 5:04 am
Location: Winchester, UK

Re: Triggering animation

Postby D'Lanor » Sat Aug 09, 2008 2:50 pm

Here is an example for opening and closing a door with a region.

Code: Select all
<region>:
    logic:
        modifiers:
          - tag: Enter_Rgn
            flags:
              - multitrigger
            activators:
              - type: objectinvolume
            conditions:
              - type: volumesensor
                satisfied: true
                direction: enter
            actions:
              - type: responder
                ref: $AnimOpen
          - tag: Exit_Rgn
            flags:
              - multitrigger
            activators:
              - type: objectinvolume
            conditions:
              - type: volumesensor
                satisfied: true
                direction: exit
            actions:
              - type: responder
                ref: $AnimClose
        actions:
          - type: responder
            tag: AnimOpen
            responder:
                states:
                  - cmds:
                      - type: animcmdmsg
                        params:
                            receivers:
                              - 006D:<animated object>
                            animname: <name of open animation>
                            cmds:
                              - setforewards
                              - continue
                        waiton: -1
                    nextstate: 0
                    waittocmd: 0
                curstate: 0
                flags:
                  - detecttrigger
          - type: responder
            tag: AnimClose
            responder:
                states:
                  - cmds:
                      - type: animcmdmsg
                        params:
                            receivers:
                              - 006D:<animated object>
                            animname: <name of open animation>
                            cmds:
                              - setbackwards
                              - continue
                        waiton: -1
                    nextstate: 0
                    waittocmd: 0
                curstate: 0
                flags:
                  - detecttrigger
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Triggering animation

Postby Nadnerb » Sat Aug 09, 2008 2:51 pm

Yes, this is possible. Try something like this:

Code: Select all
<region>:
    logic:
        modifiers:
          - name: StartAnim
            flags:
             - multitrigger
            activators:
             - type: objectinvolume
            conditions:
             - type: volumesensor
               satisfied: true
               direction: enter
            actions:
             - type: responder
               ref: :<responder name>
        actions:
          - type: responder
            name: <responder name>
            responder:
               states:
                - cmds:
                   - type: animcmdmsg
                     params:
                        receivers:
                         - 006D:<animated object>
                        animname: <animation name>
                        cmds:
                         - setforewards
                         - continue
                     waiton: -1
                  nextstate: 0
                  waittocmd: 0
               curstate: 0
               flags:
                  - detecttrigger

<animated object>:
    animations:
        - name: <animation name>
          autostart: 0
          loop: 0


Edit: this is a simpler script which simply starts the animation
Image
Live KI: 34914 MOULa KI: 23247 Gehn KI: 11588 Available Ages: TunnelDemo3, BoxAge, Odema
Nadnerb
 
Posts: 1057
Joined: Fri Sep 28, 2007 8:01 pm
Location: US (Eastern Time)

Re: Triggering animation

Postby ardent red » Sat Aug 09, 2008 3:22 pm

EDIT2: Looks like the others beat me to it, heh- I take far too long to write posts. Anyhow, good luck, and like Nadnerb's, this script only opens a door- if you want to close it too, use D'Lanor's script.

I'm trying to do this at the moment as well ekimmai, and I'm not exactly an AlcScript wizard either ;) . If you want the script without the information on how I worked it out (which could be useful when you're trying to stick scripts together in the future), it is located right at the bottom of this post. Triggering regions with AlcScript may sound impossible, but luckily for us, it can be done- Robert the Rebuilder used some code to open a door an Ahra Pahts when the avatar enters a region. Now, his AlcScript looks like this:

Code: Select all
Portal13To44:
    physical:
        physlogic: detect
    logic:
        modifiers:
          - tag: mod
            flags:
              - multitrigger
            activators:
              - type: objectinvolume
                triggers:
                  - enter
            conditions:
              - type: volumesensor
                satisfied: true
                direction: enter
            actions:
              - type: pythonfile
                ref: $click
        actions:
          - type: pythonfile
            tag: click
            pythonfile:
                file: LinkTest01Portal
                parameters:
                  - type: activator
                    ref: $mod
                  - type: string
                    value: Portal13To44


There is one main difference between this script and the one we want to make- this one sends a message out to a python script which does all the animation and the paging code. The script was written when python had to be used for animations, and the door separates the regions of Pahts so that it doesn't get to laggy, which is the function of the paging code. Now, my age isn't going to be huge, so I don't need the python file, and therefore the python-related code is redundant for our purposes.

We're going to keep most of the first bit, which just details that the things after that section need to happen after the avatar enters the region. So, our AlcScript looks like this (but it's not done yet):

Code: Select all
Portal13To44:
    physical:
        physlogic: detect
    logic:
        modifiers:
          - tag: mod
            flags:
              - multitrigger
            activators:
              - type: objectinvolume
                triggers:
                  - enter
            conditions:
              - type: volumesensor
                satisfied: true
                direction: enter
            actions:


Now we're going to attempt to make franken-script (it lives, Igor!) by splicing the animation trigger script with the region script, and then eventually joining that up that with the animation saving script ([gwiki=Saving_Object_Animations%27_States]here[/gwiki]), once I work out how to use it by itself.

As you probably know, the AlcScript for triggering an animation with a button push is the following:
Code: Select all
<object>:
    logic:
        actions:
          - type: responder
            name: <responder name>
            responder:
               states:
                - cmds:
                   - type: animcmdmsg
                     params:
                        receivers:
                         - 006D:<name of animated object>
                        animname: <name of animation>
                        cmds:
                         - continue
                     waiton: -1
                  nextstate: 1
                  waittocmd: 0
               curstate: 0
               flags:
                  - detecttrigger


The region script already contains the object.logic.action bits, so we're only going to add on the part after action. In the script below, I've removed all the refernces to Robert's objects- you need to rename all the things between the <> tags to the object/animation/region name.

Code: Select all
<region name here>:
    physical:
        physlogic: detect
    logic:
        modifiers:
          - tag: mod
            flags:
              - multitrigger
            activators:
              - type: objectinvolume
                triggers:
                  - enter
            conditions:
              - type: volumesensor
                satisfied: true
                direction: enter
    actions:
          - type: responder
            name: <region name>
            responder:
               states:
                - cmds:
                   - type: animcmdmsg
                     params:
                        receivers:
                         - 006D:<name of animated object>
                        animname: <name of animation>
                        cmds:
                         - continue
                     waiton: -1
                  nextstate: 1
                  waittocmd: 0
               curstate: 0
               flags:
                  - detecttrigger


And there you go, one (hopefully) working trigger script 8-) . Remember to assign the animation to an object using AlcScript too:

Code: Select all
<object>:
    animations:
        - name: <animation name>
          autostart: 0
          loop: <[0 | 1]>
          loopstart: <start time in seconds>
          loopend: <end time in seconds>


Oh, and one more thing: the region will work forever (muahahaha), so when you step back through the region after exiting it, the object animation will jerk back to frame one and play again. I found a rather longwinded way of preventing this by making the region animate itself into a position 100 feet into the air when you step into it, assuring that the animation would play once only. There is proabably a simpler way involving OneShotMods- if only I knew exactly what they were, other than that they're related to playing animations.

EDIT: big thanks to all the people who posted in this thread!
ardent red
 
Posts: 150
Joined: Fri Apr 18, 2008 3:41 pm
Location: The big little New Zealand

Re: Triggering animation

Postby ekimmai » Sun Aug 10, 2008 6:50 am

Wow, thanks guys. Lots of code for me to study and try out; really appreciate all the help!
I'll let you know how I fair..... :)

Ardent Red, I'm interested by your statement re separating of regions in Pahts to reduce lag - is this something I could easily incorporate if I begin to exerience lagging? Also, if I have lots of objects which are animated at different times will this affect the lag - or is lag more to do with numbers of faces and numbers of simultaneous animations??

E
ekimmai
 
Posts: 79
Joined: Mon Apr 14, 2008 5:04 am
Location: Winchester, UK

Re: Triggering animation

Postby D'Lanor » Sun Aug 10, 2008 7:02 am

The Ahra Pahts paging method is meant to reduce initial loading time. Actually this method increases lag within an age. When a shell loads it causes a lag spike.

Unless your age grows as big as Pahts the preferred method is Visregions.
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Triggering animation

Postby ardent red » Sun Aug 10, 2008 10:41 pm

Ah, D'Lanor is right- it only serves to shorten loading time. I don't *think* that this method was used anywhere in Uru by Cyan (that is, other than when you link to an age), and they had some pretty large ages- how did they keep the initial loading time small?
ardent red
 
Posts: 150
Joined: Fri Apr 18, 2008 3:41 pm
Location: The big little New Zealand

Re: Triggering animation

Postby D'Lanor » Sun Aug 10, 2008 11:22 pm

There is one example I can think of where the paging method is used inside an age: the Minkata day-night toggle.
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Triggering animation

Postby Nadnerb » Mon Aug 11, 2008 2:07 am

There is another reason why Cyan never used this method. They actually thought about multiplayer. This paging method, if used in a multiplayer environment will break uru to the point that it will probably crash in many cases.

Consider the following: Player 1 is in the red district. Player 2 is in the blue district. Player 2 presses a button that triggers a responder, sending a message to an animation in the one of the blue district pages. The message is sent to the server, which forwards it to player 1. Player 1's client searches for the target of the message so it can apply it and start the animation. However, the page containing the receiver is not paged in for player 1, so his client can't find the receiver and stackdumps.

Basically, if we want to use Pahts in multiplayer, we're going to have to deal with the long load time and just use visregions, which don't conserve memory, but help performance and don't crash things. (for now though, we're okay, since we don't have multiplayer. Eventually though, we will)
Image
Live KI: 34914 MOULa KI: 23247 Gehn KI: 11588 Available Ages: TunnelDemo3, BoxAge, Odema
Nadnerb
 
Posts: 1057
Joined: Fri Sep 28, 2007 8:01 pm
Location: US (Eastern Time)

Re: Triggering animation

Postby Grogyan » Mon Aug 11, 2008 4:03 am

ekimmai wrote:I've been playing around with alcscript in order to get some animation to be triggered by the mere presence of my avatar in a region. I had thought this would be a simplified version of the clickable region code but can't get my animation to start. Unfortunately my knowledge of alcscript is VERY limited.
Is this achievable with things as they stand in Uru and pyprp? If so could someone PLEASE give me an example piece of code to give me some ideas?

Many thanks!!
Ekimmai


Heres one that causes the avatar to execute an animation, thanks to Lontahv for this one
Code: Select all
# The empty is where the animation will start from
# this is called the seek point
<Name of the Empty for Seek point>:
   type: oneshot
    # Tell the game what animation will play
   oneshot:
      # In this case its a non global avatar animation
      # Inside the Init file you put in the full name
      # of the animation but with a prefix
      # Eg
      # Nav.PageInHold FemaleSwimDockExit
      # Nav.PageInHold MaleSwimDockExit
      #
      # These lines will hold that animation reference
      # till it gets called by the following
        animation: <Animation name>

# The name of the region to activate the oneshotmod animation
<Name of region>:
   # Has some logic referenced to it
    logic:
        modifiers:
          - tag: <Name of the triggering region>
            activators:
             - type: objectinvolume
               triggers:
                - enter
            conditions:
             - type: volumesensor
               satisfied: true
               direction: enter
            actions:
             - type: responder
               ref: <Name of the Empty for Seek point>
        actions:
          - type: responder
            name: <Name of the Empty for Seek point>
            responder:
               states:
                - cmds:
                   - type: oneshotmsg
                     params:
                        receivers:
                         - oneshotmod:<Name of the Empty for Seek point>
   


This will work with any avatar animation be it a global or non global, see the comment for dealing with non global animations
Better to have loved and lost than never to have loved at all
User avatar
Grogyan
 
Posts: 1203
Joined: Thu Oct 11, 2007 1:27 am

Next

Return to Building

Who is online

Users browsing this forum: No registered users and 4 guests

cron