Question Animation not playing on load

Jiraiya

Well-known member
Messages
480
Reactions
1,000
Points
93
Ok, so I setup a background music track. It plays fine when I click "play" on the scene animation tab.
However, when I load the scene it doesn't auto-play. How do I make it automatically play when the scene loads?
 
One method would be to use the EventAudioQueueEmpty brick of LogicBricks. In combination with a RandomSound brick it would also help you detecting when the song ended and choosing another random track.

Since the newest version of LogicBricks, which is currently in EarlyAccess, EventAudioQueueEmpty can also deal with the fact that VaM has some delay on audio loading. Right after a scene finished loading, a trigger to play audio does not do anything, its just ignored as audio loads a bit delayed. So the new version has an option to keep retrying to trigger it until it actually plays.

 
Upvote 0
The most elegant way to do this is how MacGruber wrote.
The most babaric, but sometimes much faster methode for quick scenes (and if you don't want to wrap your non-coder head around the LogicBricks)
is to simply add a collision trigger, place it within the body of a person and let this trigger the music play.
If the scene is starting, those trigger will be triggered at once.
This was a popular workaround before the LogicBricks.
Just for your info.
 
Upvote 0
I am making a "scene" and it's unlike that which you will have seen in VaM before. I am trying to avoid dependencies and using other peoples plugins. Specifically everything is handled in one script and I really don't want to start adding stuff like logic bricks. The goal is more for me to learn the scripting than achieve a particular task.
So I want to understand WHY it isn't playing on load. When I load other peoples scenes they seem to auto-start correctly?
Is it because I have no animation as such in the scene? I was wondering if I record 1 second of nothing happening and save that as the scene animation would that be enough to make it auto-play?
Is there a tickbox somewhere I am missing that makes a scene auto-play the animation on load?
 
Upvote 0
If you have scene animation (the VaM build-in animation/mocap system) I think it does auto-play, however only if you load the scene in "play" mode. If you open the scene in "edit" mode it won't.
 
Upvote 0
The most babaric, but sometimes much faster methode for quick scenes (and if you don't want to wrap your non-coder head around the LogicBricks)
is to simply add a collision trigger, place it within the body of a person and let this trigger the music play.
It's worth noting that there are a few other workarounds.

Less barbaric because there's actually an option for triggering at scene load: use AnimationPatterns. They have an "Autoplay" option. It will start automatically at scene load, so you can add whatever trigger you want here. Remove the loop and you have a scene initialization trigger.
Timeline also has the ability to autoplay an animation and launch triggers. If you're already using it for an animation that should autoplay once, it's also a good option.

I don't like Scene animations because it depends on the user launching them in Play mode. And I always load scenes in Edit mode :p
But it could be an option for scenes that are called by other scenes, as you have to be in Play mode to do so.
 
Upvote 0
Thanks for the tips! I would rather people play my scene in play mode as there will be a whole host of other things I don't want going wrong with them editing it.
However, I bet they will still load it in edit mode anyway so having it all work is more important than imposing restrictions.
I am not using ANY other peoples plugins (at least trying not to). The only thing I have so far is parentholdlink and unityassetvamifier.
While LogicBricks is amazing, I don't think it can do 100% of what I want, so I would rather not use it and have multiple things going on with different scripts.
 
Upvote 0
Back
Top Bottom