Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question AudioSource is messing up my character

Discussion in 'Audio & Video' started by jampamatos, Jun 8, 2020.

  1. jampamatos

    jampamatos

    Joined:
    Jan 26, 2019
    Posts:
    11
    Hey guys! I really need some help here!

    I've been trying to learn Unity for the past month and it's going pretty great, and now I have decided to try and make my very first game from scratch. It's going to be a very simple isomeric view voxel art 3D platformer.

    Now, I've almost completed my Player character: he runs, he jumps, he has a jetpack that gives a little boost to reach higher platforms, and it was all working perfectly.

    Until I added an Audio Source component to him.

    Now, when I press the rocket button, he starts the jetpack animation, but never leaves the floor, as if there was some unseen collision not allowing him to go up. he simply WON'T TAKE OFF and I have no idea how to fix this.

    Even if I disable the Audio Source component it won't work. But when I remove it, it works again.

    I'm thinking about adding the Audio Source to the camera and add the scripts there, but I'd really like to understand what is going on, and I'd really appreciate if I could get some help.

    Do I need to paste my Player script here?

    Thanks, guys!
     
  2. marc_tanenbaum

    marc_tanenbaum

    Unity Technologies

    Joined:
    Oct 22, 2014
    Posts:
    637
    Hi @jampamatos,

    Welcome to the forum! So...there is no realistic way that the AudioSource is exactly the problem here. Not to say that you're not correctly describing the symptoms...but there has to be something else going on. Adding the AudioSource to the camera is acceptable I guess (does that even help?), but I agree that it's better to figure out what's going wrong. Have you checked your Console to see if there are any errors being reported? That might give you a clue.
     
  3. jampamatos

    jampamatos

    Joined:
    Jan 26, 2019
    Posts:
    11
    Thanks for the welcome!

    Yeah, I cannot even hope to comprehend what's going on, it made absolutely no sense that this would happen just after I added the Audio Source component to my character. No messages in the console (apart from the messages I Debug.Logged, that is).

    I tried moving the Audio source to the child components of my char -- that is, head, arms, legs... -- but it didin't work. I tried shrinking the box collider or the size of the audiosource component, and nothing. I have no idea what to do next!

    I will try to add the audio source to the camera and see if it's going to happen, but I'd really like to understand what I did wrong!
     
  4. jampamatos

    jampamatos

    Joined:
    Jan 26, 2019
    Posts:
    11
    Well, looks like my character is having a problem with ANY audio source added to the scene. I am at a loss now.
     
  5. marc_tanenbaum

    marc_tanenbaum

    Unity Technologies

    Joined:
    Oct 22, 2014
    Posts:
    637
    Hm...doesn't make any sense to me. If you want to zip up your project I could take a look at it later today.
     
  6. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    1,306
    you have errors in the console
    only you turned off their logging
     
  7. jampamatos

    jampamatos

    Joined:
    Jan 26, 2019
    Posts:
    11
    No errors in the console. I even took one ";" off of my script to test if an error would pop out and it did, but no other errors whatsoever.

    Here you go (I uploaded it to Google Drive because I got an error saying the file was too big)

    https://drive.google.com/file/d/1-hIzo8oqU6iWqX-vjHIdynF3W4soR9gX/view?usp=sharing

    Yesterday I was angry, but now I'm most curious about it, actually
     
    r618 likes this.
  8. marc_tanenbaum

    marc_tanenbaum

    Unity Technologies

    Joined:
    Oct 22, 2014
    Posts:
    637
    Cool. I'll take a peek and let you know what I learn.
     
  9. marc_tanenbaum

    marc_tanenbaum

    Unity Technologies

    Joined:
    Oct 22, 2014
    Posts:
    637
    So no errors...but no sign of the issue either. Here's a screengrab I did.
    https://imgur.com/a/xTCgwZD

    Seems like it works fine for me with or without the AudioSource. I'm using the same version of Unity you are...only real difference is I'm on a Mac, but that shouldn't matter. I even tried replacing your entire player with just a simple cube and testing (had to add a RigidBody and an Animator to the cube of course)...works fine and no difference whether with or without the AudioSource.

    So I'm forced to think that there's something off in your setup or project. My recommendation would be to create a new project, copy over the Player code, and just recreate the test with a cube. If it works fine there, then you know there's something specific in the project. Beyond that, I'm a bit stumped.
     
    jampamatos likes this.
  10. jampamatos

    jampamatos

    Joined:
    Jan 26, 2019
    Posts:
    11
    oh my.

    will do that, and I'll let you know if it worked
     
  11. jampamatos

    jampamatos

    Joined:
    Jan 26, 2019
    Posts:
    11
    Opened up a new project and tried with a cube, and didn't work. Then I installed Unity in a new computer, loaded the project and ALSO didn't work.

    On a hunch, I decided to turn up the rocket force variable (that adds the acceleration force to the player's rigidbody) from 8 all the way up to 23 and it seems to be working. Seems kinda like audio source actually made my character heavier (?).

    It's working on the editor, but I'm a little concerned that it will add to much force to the character after I build the game.
     
  12. marc_tanenbaum

    marc_tanenbaum

    Unity Technologies

    Joined:
    Oct 22, 2014
    Posts:
    637
    Again, not really likely...AudioSource just doesn't interrelate with any of these other systems. And as you saw in my screen grab, it works fine for me. I totally get that "it works on my machine" is not an answer that helps you at all. I'm just at a loss for any explanation. Is anything different in your Player inspector from what I showed in my gif? Maybe post a screenshot of that inspector so I can look.
     
    jampamatos likes this.
  13. jampamatos

    jampamatos

    Joined:
    Jan 26, 2019
    Posts:
    11
    There you go!
    upload_2020-6-10_11-55-20.png upload_2020-6-10_11-56-2.png upload_2020-6-10_11-56-17.png upload_2020-6-10_11-56-31.png

    I also did a screengrab of what's going on:

    https://imgur.com/amiTyoh
     
  14. jampamatos

    jampamatos

    Joined:
    Jan 26, 2019
    Posts:
    11
    I built the game and it's the same bug happening, so it makes that even more strange.
     
  15. pedroarruda4991

    pedroarruda4991

    Joined:
    Jan 9, 2021
    Posts:
    20
    Hi. I had a similar problem with a project today. Try to select another object when you test the game in play mode. Don't press the play with the character selected on scene window. It's a strange bug on unity.