Jump to content

footstep sounds


awgsknite
 Share

Recommended Posts

I'm getting tired of these concrete footsteps sounds when walking on terrain and snow,etc..They all sound the same on all surfaces.

 

It doesn't make the game playable. How does one go about this idea of different footstep sounds ? I did a search here on the forums that didn't give a good answer. I read one post where it said maybe use triggered zones and another post saying use raycasting. What one is best ? Raycasting would just use the picking code in the player.lua and just make an if statement there to see what material it is ? or how ?

Link to comment
Share on other sites

raycast would be easier on your map creation stream but on the terrain I don't think there is a way to determine different types of materials (grass, gravel, blacktop, leaves,etc). you could make a grassy gravel footprint if just on "terrain" (which you can tell) to try and cover ALL terrain noises under 1 sound, and then switching to models of floors which you can get the material on and be more precise.

 

Triggers would give you much more control over this but more work by making all these triggers all over the place. It would clutter up your map.

 

But, yes you would raycast down, maybe once every few ms (not every frame as it's not needed and raycasts have a higher cost in processing I believe).

  • Upvote 1
Link to comment
Share on other sites

Pick downward from the player position every few ms with

 

http://www.leadwerks.com/werkspace/page/api-reference/_/world/worldpick-r502

 

When you get the entity picked I think you can try the following to tell if it's the terrain or not

 

if entity:GetClass()==Object.TerrainClass then

 

 

If it's just a model (I don't think csg will work for this idea) then you can get the material attached to it and tell what it is and change footstep sounds based on that with:

 

http://www.leadwerks.com/werkspace/page/api-reference/_/entity/entitygetmaterial-r127

 

 

I don't have time to show you the exact code on all of this but this should get you started. Note that you'll need to play around with the collision type parameter used in the picking to avoid picking the player itself. Your starting pick should be a little above the players y position and then down a certain range in hope to collide with whatever the player is on. You can make this picking collision something that won't collide with the players collision type but will with other collision types (essentially passing thru the player since you don't want to pick them). There is a chart that shows these collision types and their responses here:

 

http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/collision-r778

 

The collision type you specify will be checked against the entities in the world's collision type and the responses in the link above is what happens. So if in the chart the collision is None, then it'll pass thru it and won't register. I'm not 100% sure what the terrain collision type is. Maybe Scene? Play around with those settings and experiment. Use System:Print() to help you debug things (it'll show up in the console window).

 

 

If you are new to the engine or new to programming expect this to have some pain points while you figure it out. Don't get frustrated. That's just the nature of game development. Try these things and keep the things you are trying to do isolated so if you have issues you can ask specific questions about that small chunk of code that you may have problems with.

 

Good luck smile.png

  • Upvote 1
Link to comment
Share on other sites

For the record, CSG will work unless you use entity:GetClass()==Object.ModelClass exclusively. I'd also would have it compare the sounds with the materials home folder (ex: Snow/mysnowmaterial.mat) so any future materials will work automatically. You can check this with the FileSystem.

 

I plan on doing something similar myself, so just sharing what my plans are with you.

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

Me neither, but I tested it, and it works. Brushes are still objects, but not entities.

 

local p0 = self.entity:GetPosition(true)
local p1 = Transform:Point(0,-1.0,0,self.entity,nil) ---3.84
if self.entity.world:Pick(p0,p1, pickinfo, 0, true, Collision.LineOfSight ) then
if pickinfo.surface~=nil then
local pickedmaterial = pickinfo.surface:GetMaterial()
if pickedmaterial~=nil then
local surfacemat = (FileSystem:StripDir(pickedmaterial:GetPath()))
if IsDevMode() then System:Print(surfacemat) end
if surfacemat == "mymaterial.mat" then
System:Print("It works!")
end
end
end
end

  • Upvote 3

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

Will that FileSystem command work in sandbox mode? Guessing no but haven't tested. If not that might be something for the OP to consider since they are new to LE. Might not be able to use the game launcher with that command if that's the intention of the OP.

Link to comment
Share on other sites

Will that FileSystem command work in sandbox mode? Guessing no but haven't tested. If not that might be something for the OP to consider since they are new to LE. Might not be able to use the game launcher with that command if that's the intention of the OP.

 

FileSystem is a Leadwerks class so it will work in sandbox mode. The sandbox mode prevents the inherent lua modules like IO, OS, or file from working. My guess is that it doesn't load these packages/modules if in sandbox mode.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

I thought we couldn't read/write files, even from FileSystem, in sandbox mode? I though all IO was disabled in that mode? I hear you on the lua packages not being loaded but I thought the LE FileSystem stuff was also effected. I guess if I find time I could test.

Link to comment
Share on other sites

You can read but you can't write files when its enabled. Only certain commands of FileSystem will not work when sandbox mode is enabled - writing files, creating files/directories, copying files/directories, deleting files/directories... all for obvious reasons. But just reading files and directory paths is still allowed. Hence why reepblue's code with FileSystem:StripDir() will work with sandbox enabled.

  • Upvote 3

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

I guess there was a bit of misunderstanding. I had worked with the file reading stuff for the Leadwerks Player for the text loading of the notes script i have in the Steam workshop. Not on the footstep sounds.

 

Or what are you guys talking now about? ;)

 

Sorry that i can't help a lot with footstep sounds. When i got to that problem in my small map i just added a collision box. But as already said. depending on the amount etc. it could clutter up the map.

Link to comment
Share on other sites

  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...