# Visual scripting

**URL:** https://qa.fmod.com/t/visual-scripting/18354
**Category:** Unity
**Created:** [February 13, 2022, 10:23pm UTC](https://qa.fmod.com/t/visual-scripting/18354 "2022-02-13T22:23:15Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)
#### Post date: [February 17, 2022, 4:00am UTC](https://qa.fmod.com/t/visual-scripting/18354/2 "2022-02-17T04:00:56Z")

</div>

We are currently working on improving the documentation on Visual Scripting.  
Here is a basic example of how to play a continuous machine gun loop while space is held.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/9/9a270a153e428b73195629b519dc13552f6637a4.png)  
`RuntimeManager.CreateInstance` is used to create a new sound, then it is started in the enter state and stopped in the exit state. Note the instance needs to be stored in a variable otherwise we will lose our reference to it. Also note the use of `RuntimeManager.AttachInstanceToGameObject` so that the Event Instance’s transform will follow the player’s position.  
State Graph:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/2/274e82649a15e460b34f89d35e96f6d9c81b3c96.png)  
Transition to “Firing”:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/b/b05fdda7a204477d7f7d1e01e957dd65388c6682.png)  
Transition to “Not Firing”:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/0/0dee00530b07735b261c75e5af4452ea1dd9d8e1.png)

---

_[View the full topic](https://qa.fmod.com/t/visual-scripting/18354)._
