Jump to content

How would you do...


DarthRaff
 Share

Recommended Posts

Hi,

 

I have a question about how to do different sounds of different type of "terrain", for example walking over a tiled floor, concrete floor, wood flor; or for decals on different materials like glass, wood, concrete.... How would you do it ? prepare it with different gmf models of, for example, one for the floor, one for the walls, etc, and then assign them different collision types? (i don't think so, because of too many collision types), or maybe depending on the material of the models?. Anyway i don't know how to codify or edit it. Can you help me please? thankyou.

Link to comment
Share on other sites

Hi I've bin thinking about this 2.

 

It would be the most professional if you could add a line to the lua file of your model, that says which sound it plays when the player controller is moving on it. This has the problem that you need to create your floor idependent from your walls and ceiling. Tiled floors would be an option here, but that doesn't exist yet or you would have to make that your self.

 

Another possibility is perhaps adding it to the mat file. Something like this: "Soundzone: wood1". But here you would need to have some code that checks the mat file and then checks whether the player controller is in contact with the texture.

 

Another option is to send a raytrace downwards from a walking character controller. The raytrace retrieves the model ID and thereby information on what kind of model it is. Depending on the model, the information from the raytrace is then used to seek a reference in a sound tabel. When it matches a sound in the sound tabel. The corresponding sound is then being played.

 

The last option I thought of is similair to the aporach of sound zones like in FPS creator. If a player walks into this invisible box then the sound plays. The boxes can be scaled in the editor en have a sound file attached. The sound only plays when the character player is moving.

 

 

I think that one of these ways should do the trick. I like the mat file approach the best, but the only thing I perhaps can make is the last one with the sound zones. This shouldn't be to hard to create.

Link to comment
Share on other sites

That's called physics sounds. It's quite easy to make, and you can define different sounds for each material and their impact velocity (also high velocity without high impact force (like strifing) makes a different sound).

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

The sound zones is a cool idea, but is kind of a pain in the arse to setup because you have to create all these zones in your level. The mat filew ould probably be the easiest, BUT on terrain where you have different blended textures I'm not sure if that would work.

Link to comment
Share on other sites

The sound zones is a cool idea, but is kind of a pain in the arse to setup because you have to create all these zones in your level. The mat filew ould probably be the easiest, BUT on terrain where you have different blended textures I'm not sure if that would work.

It would be cool if we could add all kinds of zones to the editor. whether they are sound, trigger or ai zones. And then via the option menu you can choose to show sound zones, show trigger zones (just like show lights). This way you can make the zones and disable the view if you don't want to see them.

And the soundzones are ofcourse not for walking only. They can also set ambient music.

Link to comment
Share on other sites

You can "hack" this in. If collisions from bodies created in lua code worked it would be much better but I worked around that. If collisions worked you could have a thingoid create a body and "resize" that body from a property in code. I say resize but since you can't resize bodies and have them work right you would just be recreating the body each time you change the size of it. Then have the body follow the thingoid editor model to place it. Don't give it a mass and it'll stay there and register collision. Again, this would work all fine and great IF you have a way to know about collisions from bodies created in lua code. Currently there is no way. Collisions are only called from models that were loaded from the editor on start up. I've asked for this many times because it adds so much more functionality.

 

In the mean time I've got a way around this, BUT it's not ideal. What I'm currently doing for a Use Switch and Distance Switch is using EntityDistance() between the character and the thingoid. This creates more of a radius setup than a rectangle so there can be issues around, BUT it works well. I also have a Keyboard Thingoid that is attached to my Character thingoid. The Keyboard thingoid has a Use key property that let's you assign any key to act as the Use key. When the game starts up the Keyboard thingoid loops through all objects in the scene and saves off all Use Switch thingoids in a table local to the Keyboard Thingoid. Then when the Use key is pressed it loops through this list of Use Switches and checks EntityDistance(). If within x distance the Keyboard thingoid calls a function of the Use Switch. That in turns sends an "activate" message to all target index, which I have like Rotation Trigger, Position Trigger, etc.

 

I also have Distance Switch. What I do here is save off all these to the Character on startup. Then in the Character Update() I loop through this list each cycle and check the EntityDistance() from the character to the Distance Switch. Each Distance Switch has a distance value and this is the value to determines when to start something if the character is less than. To give a visual of the Distance Switch I create a cylinder and give a semi-transparent texture to it. When in editing mode this is visible but in game mode it's hidden. Changing the distance property changes the size of the cylinder so you can see the radius that would effect it. When then character is inside this radius the Switch method is called, which will send an "activate" message to all the thingoids attached. Once of these could be a sound trigger.

 

In a week or so I'll be releasing a game to the community that shows all of this. I've created a game with levers and rotation triggers, a basic inventory system and all done with thingoids. Right now you collect a key that has a name. For example key.blue. Then I have a Use Switch by a door. There is a rotation trigger attached to both the switch and the door. The use switch has a criteria that the inventory must have the key.blue item in order to trigger. When you have this key it calls the switches Use() method which in turn sends "activate" messages to all it's targets. In this case there is only one (the door). The rotation trigger gets this message and rotates the door (based on properties set) to open it. I do the same thing for a level and a bridge. In that case there are 2 targets. One to rotate the level and one to rotate the bridge. It's pretty cool!

 

The only thing that sucks is that because of the lack of collisions with bodies created in lua code, I have to use EntityDistance() for all this stuff. Which is slower because it's calling it every frame instead of getting a collision callback.

Link to comment
Share on other sites

Thanks. I'm kind of just waiting for a character model from Kevin Tillman. He had one for me but sold it on me >< so he said he would create another one for me :)

 

It's kind of like a dungeon puzzle game. Collect colored keys to open colored doors. Solve puzzles with switches and stuff like that. Reach the gold door to advance to the next level. My idea is to release this first version with the basic stuff and see if the lua community can make some more thingoids to add to the gameplay. I was thinking this could be a community project that people can just take and add to. Since everything is a thingoid an not in the main lua code it makes things very plug and play. When adding these thingoids it's not even programming. It's like piecing together a puzzle in itself though with the targets and such that you set. I'll post a screenshot of in editor mode and you'll probably freak out :)

Link to comment
Share on other sites

Aha, very cool.

 

Well, when i was using Blitz 3d about a year ago, i had a system to hide or show the zone where you are and the adjacent zones. I were using 3d world studio like that: i create a zone and then put a entity in the -x,-y,-z position of the zone and take the coordinates, then move the entity to +x,+y,+z and take the coordinates. Then, Put this coordinates in the properties of the zone with the anterior zone and posterior zone too and delete the entity (je,je not very professional, but functional), then, in code, i had a system to take that coordinates from the entity, and use them to check if the player IsInsideZone(whatever number) and show the zones that are in the properties and hide the others. Maybe we can use something similar to check the sound-trigger-whatever zones without any collision needed and can do it in the editor, but i don't know if this system is too expensive in game play or not. :)

Link to comment
Share on other sites

Maybe we can use something similar to check the sound-trigger-whatever zones without any collision needed and can do it in the editor, but i don't know if this system is too expensive in game play or not.

 

Might be able to do AABB checks also.

Link to comment
Share on other sites

Yes, Rick, it is able to do AABB.

 

 

Maybe the ForEachEntityAABB function that Chris Paulson mentioned is not compatible with lua but we can create the our own one if it is not compatible.

 

 

The problem is, yes, the impossibility of change the size of the model you use with the editor, but its not necessary to have a model. just putting an entity in -x,-y,-z to take the coordinates and then move it to +x,+y,+z to take that coorditates and creating the zone in code with the properties of the entity previously moved to the center of the imaginary zone,i the editor, of course.

Link to comment
Share on other sites

That doesn't happen to me. Maybe it's how you are doing it

I don't mean scaling via code or the lua option. I mean the scaling gizmo. For example: I scale a placed oildrum placed in the scene using the scale gizmo. when I go into game mode the scale is ok. But when I go out of the game mode, back into the editing mode, all the scales are being reset.

Link to comment
Share on other sites

I don't mean scaling via code or the lua option. I mean the scaling gizmo. For example: I scale a placed oildrum placed in the scene using the scale gizmo. when I go into game mode the scale is ok. But when I go out of the game mode, back into the editing mode, all the scales are being reset.

 

Oh I see. I have to be honest there are very few times that I actually use the model loaded from the editor. Most of the things that require some sort of functionality I make a thingoid and then have a scale option as a property and that works great! :)

 

Maybe the ForEachEntityAABB function that Chris Paulson mentioned is not compatible with lua but we can create the our own one if it is not compatible.

 

Yeah, that's what I was pointing out that the function isn't available. Wouldn't you still need to loop through every entity though to check the AABB?

Link to comment
Share on other sites

Yes, i have to iterate through every entity and it is too expensive i think, but it's not necessary to do it in lua. It can be done in c++. It will not be possible to see the result in the editor but it is possible to do by code and use ForEachEntityAABB. Well, it depends on the needs of everyone but, anyway, i don't know what is the best way to do that.

Link to comment
Share on other sites

In reply to the original problem, I would make a strict top-down render of the level in question in Max. I would then go into Photoshop and quickly paint over it in different solid colors, depending on the area being painted over, like yellow for sand, gray for concrete, blue for water and so on (essentially creating sound zones by drawing them).

 

Then, in-game, I would get the character's x/y position, get the color on the drawing at that location and play a sound depending on what color was picked up. It gets just a touch more complex if you have an area with multiple heights.

 

This is my preference mostly because I know how to do each step and is easy for me, not because it's the simplest.

Link to comment
Share on other sites

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...