CGTalk > Software > Autodesk Maya > Maya Character Setup
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 02-22-2013, 06:15 AM   #1
hellspawned
Know-it-All
Tomas Landberg
Huddinge, Sweden
 
Join Date: Sep 2004
Posts: 430
An animation loop toggled on/off by a control?

Hello!

I'm making an automated turret, and it needs to be able to fire it's cannons. As it is quite a fast and repetitive action, one would imagine that it would be best to do one fire cycle, then repeat it and hook it up to an on/off controller, right? But how do I do that, exactly?
 
Old 02-22-2013, 03:30 PM   #2
shinyprem
Expert
 
shinyprem's Avatar
portfolio
Prem Anand Earnest Dhass
Team Lead Rigging
Technicolor India
Bangalore, India
 
Join Date: Sep 2006
Posts: 600
Send a message via Yahoo to shinyprem
Hi,
SDK the turret rotation and connon firing for one cycle. Then grab the SDK DAG node open the attribute editor and make it cyclic. Now as you play the timeline your turret will rotate and fire.
Rgds,
__________________
Prem
Download vehicleRigGenerator @ http://www.creativecrash.com/marketplace/44706
 
Old 02-22-2013, 04:04 PM   #3
Nyro
Lurking
 
Nyro's Avatar
portfolio
A. D.
Vertex Slinger
Munich, Germany
 
Join Date: Dec 2006
Posts: 1,436
Here's how I would do it, though that's not to say it's the best method; merely the one I could think of right now:

  1. Animate your gun fire cycle normally. Make sure you set the animCurves to cycle in pre- and post-infinity.
  2. Disconnect the animCurves from the animated attributes (use the hypergraph for this; don't use 'break connection' in the channelbox as this will also delete the animCurves)
  3. Animate the gun again, but leave the animation static, i.e. just set one key somewhere on all previously animated channels
  4. Disconnect the new animCurves again
  5. Create a choice node for each animated attribute, add 2 inputs per choice node
  6. Connect the 'static' animCurve.output attribute to the choice.input[0], and the 'animated' animCurve.output to choice.input[1]. Do this for each attribute/pair of animCurves/choice node.
  7. Create an integer attribute on some object which you want to use as the 'on/off' switch
  8. Connect that on/off attribute to the choice.selector attribute

This way, the choice node acts as a 'router' or 'inhibitor'. Only when the on/off attribute is set to 1 do the cycled animated animCurves get connected to the gun, at which point it begins firing. When set to off (0) the static animCurve gets connected and the gun doesn't fire.

An alternative, with less setup hassle, might be to simply connect some on/off attribute to each animated animCurve's Node State attribute, switching it from Normal to HasNoEffect (though I haven't tested this)
 
Old 02-24-2013, 11:02 PM   #4
hellspawned
Know-it-All
Tomas Landberg
Huddinge, Sweden
 
Join Date: Sep 2004
Posts: 430
Quote:
Originally Posted by Nyro
Here's how I would do it, though that's not to say it's the best method; merely the one I could think of right now:


  1. Animate your gun fire cycle normally. Make sure you set the animCurves to cycle in pre- and post-infinity.
  2. Disconnect the animCurves from the animated attributes (use the hypergraph for this; don't use 'break connection' in the channelbox as this will also delete the animCurves)
  3. Animate the gun again, but leave the animation static, i.e. just set one key somewhere on all previously animated channels
  4. Disconnect the new animCurves again
  5. Create a choice node for each animated attribute, add 2 inputs per choice node
  6. Connect the 'static' animCurve.output attribute to the choice.input[0], and the 'animated' animCurve.output to choice.input[1]. Do this for each attribute/pair of animCurves/choice node.
  7. Create an integer attribute on some object which you want to use as the 'on/off' switch
  8. Connect that on/off attribute to the choice.selector attribute
This way, the choice node acts as a 'router' or 'inhibitor'. Only when the on/off attribute is set to 1 do the cycled animated animCurves get connected to the gun, at which point it begins firing. When set to off (0) the static animCurve gets connected and the gun doesn't fire.

An alternative, with less setup hassle, might be to simply connect some on/off attribute to each animated animCurve's Node State attribute, switching it from Normal to HasNoEffect (though I haven't tested this)



It works as far as I have tested (haven't animated my character yet, still testing and working out the kinds of the rig).



One question though: When I turn the animation on, will it begin at frame 1 of the animation curve, or wherever in the looping animation it happens to be at the time? It's not such a big deal with this specific animation since it's such a short repetition, but when it comes to longer animation cycles, it would be good to be able to have it offset to the frame(s) where the animation is set to on, rather than jumping into it at some random place in the middle of the cycle.
 
Old 02-24-2013, 11:07 PM   #5
Nyro
Lurking
 
Nyro's Avatar
portfolio
A. D.
Vertex Slinger
Munich, Germany
 
Join Date: Dec 2006
Posts: 1,436
No, it will play at whatever frame the scene time currently is; animation curves are a function of value over time, and time is the global time.

If you want it to start at frame 1, then you'll have to write a script(job) to do the work, though perhaps it could be done with an expression.
 
Old 02-24-2013, 11:07 PM   #6
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 05:00 AM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.