Unity - Play Sound Effect During Collision (OnCollisionEnter2D) | EASY Unity Tutorial

preview_player
Показать описание

SKYPE: rafa.v35
Рекомендации по теме
Комментарии
Автор

Thanks so much! Didn't know I could use this on games, used it on a coding assignment last year, lol!

FookerCarlson
Автор

Thanks buddy, I've been searching for so long, for a good tutorial simple and working <3

SkopidOHNS
Автор

Thank you so mush! Creating a new gameobject solved my problem.

Tony-unmg
Автор

but I want this for like bullets hitting and exploding on a surface and an impacteffect particle system gets instantiated and then like all the gameObjects like my "bullet" and my "explosion" disappear - so I am guessing that instead of my audiosource being a gameObject I should make it a prefab? But wait a minute your tutorial is really good - as I was looking at this initially the wrong way - like I was focusing too much on tying my "explosion" to the bullet or impactEffect which gets destroyed - and Unity of course bitches about unable to play a null sound and all that B.S. - so aha, keep the audioSource as like it's own separate public gameObject and have the script refer to it - but even when the bullet and the impactEffect get destroyed, my audio gameObject "remains" in the game and no more audio errors? thanks a million. I'll try it.

TakaShitake-rtbz
Автор

Thanks buddy but jumpscare is something different from scaresound!

nikocounters
Автор

Do you have any code methods where when the player collides with an enemy it knocks the player backwards a bit with a stun? Kinda like old mega man and castlevania games for example

xDTHECHEMISTx
Автор

I'm going bonkers, I tried several things in my 2D Panchinko project to get a sound to play when the ball collides with one of the pegs, nothing is working, I have tried with and without tags, moving code around in C#, moving the order of components, literally nothing is working, the sound simply won't play and I don't know why :/

dj_tika
Автор

does the audio file have to be a specific type? i did everything you said but wont let me put the audio file into the audio player

NoobNoob
Автор

How do I get my enemy to play a sound when my player gets close to the enemy?

jawbytes
Автор

yeah - just like bullets and impactEffects that disappear from the world are handled via prefabs, I'm now inclined to conclude - that my audioSource instead of a gameObject sitting in the hierarchy - needs to be also a prefab - and I need to code an instantiation of the audioSource prefab that gets played when the bullet collides with a target I want it to "ricochet" off etc. hmm. ok you really set me on the right path with this thanks - this is a b*tch for when you want to apply to objects that get destroyed like projectiles and explosions - they are there one update loop but then gone on the next iteration of update lol

TakaShitake-rtbz
welcome to shbcf.ru