OBJECT RESPAWN SCRIPT
Remember that water balloon we made in the Gizmos series? We are going to turn it into a game mechanic. Before we get started, I recommend building a base for the balloons to originate from and respawn to. Then, we are going to create a return script so that the balloons go back to their starting position.
From the WaterBalloon script, bring over When World is Started, and then from the Values tab, grab two SetTo codeblocks. On our Variables tab we will create an origin position vector variable, and an origin rotation, rotation variable. We can then bring these variables to the left side of the SetTo codeblocks.
On our Operators tab, under Object Transform, bring over Position of Object, and Rotation of Object. From Values we can get Self. Now on World Start, we set Origin Position to the Position of Self, and Origin Rotation, to the Rotation of Self.
You’ll remember in the Reapper event we moved the balloon up by 50 meters, let’s delete this codeblock and from our Motion tab, bring over the MoveTo and RotateTo codeblocks. Please note these are the Instant Motion variants. We can now replace the Vector and Rotation values with the origin variables we created.
Awesome, these balloons will now return after hitting players, great work!