About Store Forum Documentation Contact
Donations:
167$/mo



Post Reply 
Emit 3d Sound on collision
Author Message
tipforeveryone Offline
Member

Post: #1
Emit 3d Sound on collision
Anyone give me an example code of this

Barrel drops on ground and emit 3d sound at the time it collides.
and it only emits sound if speed is above a value
(This post was last modified: 06-14-2020 10:54 AM by tipforeveryone.)
06-14-2020 09:23 AM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #2
RE: Emit 3d Sound on collision
Code:
void ReportContact(ActorInfo &actor_a, ActorInfo &actor_b, C PhysContact *contact, Int contacts)
{
  FREP(contacts)
{
   Vec force=contact[i].force;
   if(force.x<0)force.x=-force.x;
   if(force.y<0)force.y=-force.y;
   if(force.z<0)force.z=-force.z;
   if(force.sum()>25)
   SoundPlay(soundUID, contact.pos);
}

then do something like this in Init()
Physics.reportContact(AG_TERRAIN, AG_DEFAULT);
Physics.reportContact(ReportContact);
06-14-2020 12:15 PM
Find all posts by this user Quote this message in a reply
tipforeveryone Offline
Member

Post: #3
RE: Emit 3d Sound on collision
Thank you! I made it emit sound on collision. But does this only handle one type of actor object ? what if I have various objects in one Actor Group and I want each of them to emit their own collsion sound ?
06-16-2020 10:03 AM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #4
RE: Emit 3d Sound on collision
(06-16-2020 10:03 AM)tipforeveryone Wrote:  Thank you! I made it emit sound on collision. But does this only handle one type of actor object ? what if I have various objects in one Actor Group and I want each of them to emit their own collsion sound ?

you can cast the actor_a.obj or actor_b.obj to their derived game objects if I remember correctly.
(This post was last modified: 06-18-2020 12:34 PM by Zervox.)
06-18-2020 12:32 PM
Find all posts by this user Quote this message in a reply
Post Reply