Hi all… it’s entirely possible that I’m massively overthinking this. I’ve been trying a tonne of stuff that’s probably way more complicated than is necessary (and none of which has worked anyway ) so am shouting out here to ask if there’s a way to do the following.
I have a video in my unity scene that plays via a Playable Director (which is started by the user clicking a button). I’m trying to find a way to ‘reset’ the video when it’s finished playing, so that instead of either ‘holding’ or ‘looping’ it simply goes back to its beginning and stops, to await being restarted (if required) by the user repeating the button interaction.
Any advice will be gratefully received, as always … the struggle is real (video reel )
Hello there – I’m an AI powered assistant that might be able to help you with your question. Would you like me to try helping you?
How it works:
Reply to the messages of the bot that end with a thread_id to interact with it and ask follow-up questions. You can also mention the bot directly in this channel to get help.
Hi Frannie, it seems you want to reset a video controlled by a Playable Director in Needle Engine after it finishes playing. Based on the Needle Engine types documentation, the PlayableDirector class provides play(), pause(), and stop() methods that you can utilize to control the playback of the timeline (see the documentation).
To reset the video when it finishes, you would typically add an event listener or a callback that is triggered when the video ends. In Needle Engine, you might have to manually check if the video has ended by comparing the current timeline time with the duration and then call the stop() method, which presumably resets the timeline for you. After calling stop(), you can set the time property of PlayableDirector back to 0 to ensure it’s at the beginning. Here’s a simplified version of the code you may want to include in your component:
class YourCustomDirectorBehaviour extends Behaviour {
private playableDirector: PlayableDirector;
// Other methods and logic...
update() {
if (this.playableDirector && this.playableDirector.isPlaying &&
this.playableDirector.time >= this.playableDirector.duration) {
this.playableDirector.stop();
this.playableDirector.time = 0; // Reset timeline to start
}
}
// Event handler when user clicks a button
onUserClick() {
// As an example, assuming the PlayableDirector is assigned to this component
this.playableDirector.play();
}
}
You’re welcome, Frannie! Feel free to give it a try, and if you encounter any issues or have further questions, don’t hesitate to ask. Good luck with your project!
@Needle Engine Assistant, sadly this didn’t work for me, as it doesn’t specifically target the video.
After it’s played I need the video to go back to the beginning and stop, so that it can be played again (in entirety) whenever the user wants to view it.
So, I’m still trying different things in the hope of finding a way forward
Good question re: PlayableDirector use!!! I did say that I was probably overthinking all this
On reflection, I think I can probably achieve what I want using ‘Play Animation on Click’. I’m off to give that a try right now. I’ll shout up here with news of success or failure
Have you tried adding a button component to your object and from the button first call video.stop() and then add another event (2nd) to call video.play() ?