Actor make a sound when player walks through it - how?

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!)
Post Reply
User avatar
Enjay
 
 
Posts: 27140
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Actor make a sound when player walks through it - how?

Post by Enjay »

I have a very simple ZScript decoration. It has no collision and minimal height, and it simply exists to allow a flat-plane model to be placed in game. The model looks like a drain cover and doing it this way allows me to place drain covers wherever I need them to be without being tied to the appearance of background flats and flat offsets.

However, it would be nice if, as the player walked "on" (i.e. through - but bear in mind the actor is only around 1 or 2 units tall IIRC) the actor made the "clang" sound of the player walking on a metal surface.

What would be the best way to do that? I'm sure that a bit of cunning ZScript code could probably check that the player had entered the actor's bounding box and make a sound, but I don't know how to do it. Can anyone suggest/share code for that feature?

I could do it by making a 64x64 sector everywhere that I place the actor and just use ACS scripting to make the sound when the player enters the sector, but that kind of defeats some of the purpose of having a flexible actor that can be placed anywhere.
Post Reply

Return to “Scripting”