i’m new and just doing this for class, is there anyone who can help me find a solution.
so i have a fps game, and i need to play a different sound per object when it collides with the bullet.
can someone teach me how to do this? thanks
@migs1 Welcome! This forum and its history are the place to find answers to your questions. The question you are asking probably has answer by searching the forum. Here is a quick search.
@migs1 I am not sure what method you would be using to fire the bullet at the item but if the rigidbody of a physical bullet collides with the object then you could use the method below in this example.
// Enter trigger
ItemPickup.prototype.onTriggerEnter = function(object) {
if(object.tags.has('player')) {
// play the pickup sound
if(this.entity.sound) this.entity.sound.play("Pickup");
// increase the munitions amount
console.log("pickup");
// Increase item amount
object.fire("player:addhealth",this.amount);
// Disable after Pickup
this.entity.enabled = false;
}
};
This script basically play the sound attached to the object when the player runs over top of it. One thing you will have to do is attach the sound like this.