URGENT HELP TO SAVE MY DEGREE PLEASE GET BACK TO ME BEFORE THE 22ND

So I was given, without my consent, an extended module on my sound design course where I have to create sound effects and put them into a premade game on the unity engine. I have no idea how to script and have literally never used the program before.

Adding them to prefabs was easy, I just dragged them in. But for a certain subsection of the prefabs, known as interactables, I will need to script the sound to play on contact (for items like keys and pickups) and when pushed or triggered (a door opening and pushing a block). If anyone can help me do this before my deadline I will be in your debt and can offer payment.

  • using UnityEngine;
  • using System.Collections;
  • //Add this Script Directly to The Death Zone
  • public class SawSoundController : MonoBehaviour
  • {
  • public AudioClip saw; // Add your Audi Clip Here;
  • // This Will Configure the AudioSource Component;
  • // MAke Sure You added AudioSouce to death Zone;
  • void Start ()
  • {
  • GetComponent ().playOnAwake = false;
  • GetComponent ().clip = saw

This is a script I tried to use, but I don’t know what it means or why it doesn’t work, (I did cut out the instructions and input my sound name)

Sorry if my post came off as brash, desperate or stupid, I have great respect for all of you who managed to learn this super complicated program, and if anyone could take some time to help me,

Better fix that first! See below for how to do tutorials properly. It’s not optional.

Remember: NOBODY here memorizes error codes. That’s not a thing. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.

The complete error message contains everything you need to know to fix the error yourself.

The important parts of the error message are:

  • the description of the error itself (google this; you are NEVER the first one!)
  • the file it occurred in (critical!)
  • the line number and character position (the two numbers in parentheses)
  • also possibly useful is the stack trace (all the lines of text in the lower console window)

Always start with the FIRST error in the console window, as sometimes that error causes or compounds some or all of the subsequent errors. Often the error will be immediately prior to the indicated line, so make sure to check there as well.

All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don’t have to stop your progress and fiddle around with the forum.

Tutorials and example code are great, but keep this in mind to maximize your success and minimize your frustration:

How to do tutorials properly, two (2) simple steps to success:

Step 1. Follow the tutorial and do every single step of the tutorial 100% precisely the way it is shown. Even the slightest deviation (even a single character!) generally ends in disaster. That’s how software engineering works. Every step must be taken, every single letter must be spelled, capitalized, punctuated and spaced (or not spaced) properly, literally NOTHING can be omitted or skipped.
Fortunately this is the easiest part to get right: Be a robot. Don’t make any mistakes.
BE PERFECT IN EVERYTHING YOU DO HERE!!

If you get any errors, learn how to read the error code and fix your error. Google is your friend here. Do NOT continue until you fix your error. Your error will probably be somewhere near the parenthesis numbers (line and character position) in the file. It is almost CERTAINLY your typo causing the error, so look again and fix it.

Step 2. Go back and work through every part of the tutorial again, and this time explain it to your doggie. See how I am doing that in my avatar picture? If you have no dog, explain it to your house plant. If you are unable to explain any part of it, STOP. DO NOT PROCEED. Now go learn how that part works. Read the documentation on the functions involved. Go back to the tutorial and try to figure out WHY they did that. This is the part that takes a LOT of time when you are new. It might take days or weeks to work through a single 5-minute tutorial. Stick with it. You will learn.

Step 2 is the part everybody seems to miss. Without Step 2 you are simply a code-typing monkey and outside of the specific tutorial you did, you will be completely lost. If you want to learn, you MUST do Step 2.

Of course, all this presupposes no errors in the tutorial. For certain tutorial makers (like Unity, Brackeys, Imphenzia, Sebastian Lague) this is usually the case. For some other less-well-known content creators, this is less true. Read the comments on the video: did anyone have issues like you did? If there’s an error, you will NEVER be the first guy to find it.

Beyond that, Step 3, 4, 5 and 6 become easy because you already understand!

I would love to be able to go through like that, understand fully and fix the problem through exclusively my own knowledge. Thank you for typing that all out, and I will definitely give it a try. However, I only have until the 22nd. Is it possible for you to link me to a script to play a sound when the player comes into contact with an item with a reeeeal baby step explanation?

The purpose of this forum is to assist people who are ready to learn by doing, and who are unafraid to get their hands dirty learning how to code, particularly in the context of Unity3D.

This assumes you have at least written and studied some code and have run into some kind of issue.

If you haven’t even started yet, go check out some Youtube videos for whatever game design you have in mind. There are already many examples of the individual parts and concepts involved, as there is nothing truly new under the sun.

If you just want someone to do it for you, you need go to one of these places:

https://livehelp.unity.com/?keywords=&page=1&searchTypes=lessons

Yeah, I understand that it is inappropriate to solicit help the way I am, and I mean no disrespect to people like you who have spent countless hours learning the software. I am not looking for a fully completed script that fixes all my problems, but perhaps a link or pointer to a forum page that explains how to make a prefab make sound on pickup.

I do not have the money, time, or desire to purchase help and have someone complete my course for me. But if you know where I can find more accurate help It would be appreciated.

Thanks for all your time my dude.

If you are unable to pick this up from the first three (3) Youtube tutorials that come up when you ask that question, I’m not sure why you think you’d be able to understand what some rando types in a goofy little text box here!

Good luck!

Searching on YouTube for something so specific has not offered any merit. I have talked to various people, been on YouTube and forums and pretty much everything under the sun. The only issue is that every game is so unique that there is always

I was hoping asking directly on the forums would offer a more targeted response, where someone with expertise could link me directly to something more relevant to my topic.

Is learning scripting and unity supposed to be part of your course?
It’s not that easy to learn that you can just figure it out in a short span of time with no experience in coding or unity…

1 Like

Why not just contact your tutor and get them to give you the more indepth help that you need? Thats what they are there for, even if your close to a deadline on a longterm assignment.

If they cant/wont help maybe they can give you an extension to figure it out yourself, what you need is fairly easy and any shooter tutorial will cover pickups at some point. The tutorials on the unity website will definitely cover it aswell.

From your description you were given a premade project so I expect its already partly done for you its just been poorly explained.

Yeah, I suspect that they have included the scripts you would use in the project, and you would just have to drag and drop your audioclips onto the scripts, and possibly drag and drop the scripts themselves onto the prefabs.

I really don’t see the point in them expecting you to copy paste a bunch of code you won’t understand, seeing as though that has nothing to do with sound design, and it also doesn’t teach you programming, so I’m guessing that’s not what’s happening.

Yeah basically I make beats and I am on a music production course and due to my own incompetence they chose an elective module for me (basically an add on to the course) as I had only chosen 2 and I needed 3. They decided to put me on games design, and this particular course requires me to add sound effects to a precoded unity game. On certain areas it is easy, but I assume I am expected to script the sound effects in for keys myself. They do come with their own audio source, but no code specifying to play a sound on pickup. My tutor will not respond to me, my lesson videos are broken (and the tech support says It will take 3 days to get them back up) and so I am resorting to just asking you guys, and can I just thank you all for actually taking time out of your day to message in this forum.

I am not expecting to understand unity in a few days without coding experience, I just need enough to put a sound in. I am sure I can figure that out with come guidance, though I am currently watching every tutorial I can get my hands on.

Does anyone have a script that specifies when an object is picked up it plays a sound? And how exactly would I link that to the audio source on the key?

Looks like the 2D Game Kit project

Watching the trailer on the assetstore, it says that it is a project made for artists to practice in without having to code.

The interactables have events that you can hook up to, to play sounds and react on collisions/triggers etc in other ways as well. That’s how you would play your sounds, without coding, because it’s already coded.

The trailer is here:

Tutorials for the project are here:

A reference guide and advanced topics are also linked

The health pickup and the interaction system would be useful to look at on this page

In advanced topics you also have a random audio player that is also used in the project:

Basically, you would click on one of those pickup prefabs, find the attached script component associated with calling events when it is picked up, and replace the audioclip that it is playing with your own by dragging and dropping the clip.

1 Like

Thank you loads man, uhh it’s good that I got the baby wheels on.
Yeah, it works that way for most prefabs, but many interactables do nothing when the sound is dragged in.

Sound script on collision :

using UnityEngine;


// place sript on colision object
// place file sound in MyFileSound, in inspector script
// Tick "is Trigger" on box collider in colision object
// create component Audio Source in colision object, no need modify option

public class NameOfScript : MonoBehaviour
//"NameOfScript " must have the same name as your script
{
   // ----------Here my variables----------------

    public AudioClip myFileSound;
    private AudioSource playerAudio;
 

 // -----------Here what is read at the start of the game---------------
 
    void Start() {
    playerAudio = GetComponent<AudioSource>();
    }


    // -----------Here what is read during the collision between the two objects---------------

    void OnTriggerEnter(Collider col) // col Name of Collider
    {
        if (col.name == "NameOfCollisionOject")    // "NameOfCollisionOject" name of second gameObject collision.
        {
    playerAudio.PlayOneShot(myFileSound);
        }
    }
}


//"OnTriggerEnter" when my player collides with the object
//"OnTriggerExit" When he goes out
//"OnTriggerStay"when he's inside

I didn’t quite understand what you want, detail exactly what you want.

For your script I do not know it is incomplete.

The variable “public AudioClip saw;”

  • public : means you can interact with it in the inspector!!!
  • AudioClip : the variable;
  • saw : the name you give to your variable to reuse it in your script.

Did you add your sound file in the inspector?

I suppose that if you click on the key object, you must have a script attached to it, it will be enough to modify it a little so that the sound plays.

Closed. Violates many rules and simply is not the place for this.

1 Like