Hey and welcome!
This might be a bit of an odd one today. My current task with this project is to add in an Elevator, Moving Platform and a Collectable which all may sound very familiar to you as we’ve already implemented these before.
There are a couple of tweaks I’ll be doing but the interesting part here is that since I started a new project for making use of URP I don’t actually have the code or objects anymore. So now the task here is carrying over the code from the previous project and implementing it in the new one (no sense in abandoning some perfectly good code!).
Now there’s a few ways you can go about doing this, the first is to open up the file explorer and navigate to the scripts folder in your current project and your old project and simply drag and drop the files over.
If you have your current project open in Unity you can open your old project in your file explorer and drag and drop the files directly into Unity instead.
The last option I can think of is that you can open up your old scripts and copy and paste them over into your new script, not particularly handy in this instance but useful if you only wanted particular parts of the script.
Doing all that though presents an issue since the Coin script is trying to access an AddCoins method from the player, however since I’ve created a new script and project I don’t have that method or the UI element that I need so I’m going to add those in real quick.
Before I get onto the Elevator and Moving Platform I’m going to show you something a little new with what I have planned for the collectable. Currently I’ve swapped out the sphere and replaced it with a coin now. To give it a bit more life I’m going to add my own animation to it. If you remember you can click on the object you wish to animate and choose the create option in the animations window.
I think one full rotation every second will work well. Similar to what we did for the virtual cameras when using cinemachine go ahead and click the record option and enter in the start rotation for your coin, for me I set it to 90 on the y axis.
With that done move the timeline slider over to the 60 second mark and then rotate your coin 360 degrees and click the record button again then test out your animation.
It may create an animator controller for you already but if not go ahead and create one now and drag and drop your animation in there making sure that animation is set to loop. Now add an animator component to your coin object and add in this controller to it.
That’s not looking too bad! When you’re happy with it make sure to prefab the coin object so you can make use of it multiple times in your game.