AttackGorilla Posted September 23, 2020 Share Posted September 23, 2020 In the Unigine basic water tutorial it shows how to get splash particles triggering as sparks when objects interact with the water. Is there a similar method that can be used, or a way to trigger off that spark particle, to trigger a "splash" sound when objects interact with the water mesh? (if not what is the suggested approach to get sounds to trigger when objects interact with water mesh?) Link to comment
cash-metall Posted September 23, 2020 Share Posted September 23, 2020 Hello! You need to write additional logic to implement this. in each frame you need get Body from ObjectWaterMesh and check each contact (Body::getNumContacts), for each contact you can get some info (Body::getContactPoint , Body::getContactImpulse, Body::getContactNormal) according to this information you need to create SoundSource and play it Link to comment
AttackGorilla Posted October 20, 2020 Author Share Posted October 20, 2020 Was working on some other things in my game and finally got around to trying this again. Can anyone confirm that callbacks work for BodyWater? I am using C# and using the callback method in my other bodies (Rigid, Dummy, Fracture) all work fine. Utilizing the same callback code (copy/paste) from those bodies into the BodyWater is not producing any callbacks for me... bw = new BodyWater(watermesh); bw.AddContactEnterCallback(contact_callback); . . . if (callbacks.Count > 0) { for (int i = 0; i < callbacks.Count && i<100; i++) { contact_callback_handler(callbacks[i].body, callbacks[i].num); callbacks.Remove(callbacks[i]); } callbacks.Clear(); } . . . public void contact_callback(Body body, int num) { callbacks.Add(new ContactArguments(body, num)); } public void contact_callback_handler(Body body, int num) { if (num >= body.NumContacts) return; Node effect = World.LoadNode(ReferenceNode); effect.WorldPosition = body.GetContactPoint(num); } Link to comment
silent Posted October 22, 2020 Share Posted October 22, 2020 AttackGorilla There is no ContactEnterCallbacks for BodyWater, so your code isn't working. We are thinking to implement them in the future versions (can't say the exact one unfortunately). Thanks for pointing that out! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
AttackGorilla Posted October 22, 2020 Author Share Posted October 22, 2020 Thank you for letting me know. Is there any suggested workaround? Do you know if there is a way for another Body (like fracture body) to know it has contacted the water body? Link to comment
silent Posted October 22, 2020 Share Posted October 22, 2020 The workaround is already available in the previous post: How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
AttackGorilla Posted October 23, 2020 Author Share Posted October 23, 2020 Great. Thank you. That is working. Now I just need to figure out how to code the contact to only trigger periodically and not upon every frame... Link to comment
Recommended Posts