Problem With Rotation Speed and Problem With Audio

I have been following a Udemy guide to Unity: https://www.udemy.com/become-a-game-designer/


It has its problems with being up to date, but I have been able to solve most of them until now. First off the rotation speed doesn’t change even if I change it from 20.0f to 100.0f.


Here’s the code:

Fixed code:


The other problem is with sound. It gives me an error saying this:
Assets/Scripts/TriggerEvent.cs(18,10): error CS1061: Type UnityEngine.Component' does not contain a definition for PlayOneShot’ and no extension method PlayOneShot' of type UnityEngine.Component’ could be found. Are you missing an assembly reference?


Here’s the code for that:

Fixed code:


I’m pretty new to Unity and I don’t know how to solve this. Thanks in advance.

In the first code you never used the rotationSpeed variable, you used speed and -speed instead of rotationSpeed in your rotate function.
For the audio one I’m not too familiar with audio but it seems you didn’t assign anything named audio or PlayOneShot.
Hope this helps!

Hi @connoradams251
For your problem with playOneTime:
First your object must have an audioSource attached or have a reference to a source in the scene.
Then you must give it a reference to a clip.
Then you must call PlayOneShot which is in the audioSource with the following args:

  1. Required: The clip to play.
  2. Optional: The volume scale.
    And thats it!