Playing sound when touching a passable actor

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
Cherno
Posts: 1321
Joined: Tue Dec 06, 2016 11:25 am

Playing sound when touching a passable actor

Post by Cherno »

I have a bunch of jungle plants and I would like to play a "rustling leaves" sound when the player touches ( = goes through) the vegetation. The plant itself should be passable, of course. Is this possible? I don't want to create small sector lines around each plant with Linedefs actions.
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

Re: Playing sound when touching a passable actor

Post by Apeirogon »

In zscript, yes. You only need override can collide with virtual, like

Code: Select all

class bush : actor
{
override bool cancollidewith (actor other, bool passive)
{
if(other)
{
a_playsound(rustling leaves);
}
return false;
}

other actor stuff
} 
In decorate you need workaround. Like spawn harmless projectile in position on bush, which at "attack" play rustling leaves sound, or try to use acs and a_warp functions.

Return to “Scripting”