Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
walking sounds from different terrain

Robo
Guest
Quote
2020-04-06 10:36:24

I believe the best way to change the walk sounds from different terrain texture is to place invisible squares over non standard textures (non default) and link these to a js query that looks at the distance between them and the player to determine when to change sounds.

I will feed into the existing walk sounds extension a variable that will change the name of the sounds it will next play.

I think this is the best idea to fix this...anyone care to comment ?


blackwater
Registered User
Quote
2020-04-12 23:34:28

Interesting. I've solved it just by making collision boxes and using variables for each surface. It takes some time but works. A simple script that is less time consuming than my method would be much appreciated.


Robo
Guest
Quote
2020-04-15 11:07:28

wrote:
Interesting. I've solved it just by making collision boxes and using variables for each surface. It takes some time but works. A simple script that is less time consuming than my method would be much appreciated.


Well I thought about what you mentioned but if you have dozens of separate tiles then you would need a separate proximity check for each one which doesn't sound good for performance.

I opted for a more complex yet more efficient way to group tiles into sections and only look at a section at a time rather than every single one constantly which should run faster that way. When its done will post a demo...


just_in_case
Moderator
Quote
2020-04-15 15:43:21

Try using the same method i used to create line of sight in my age of empire clone demo.... It checks the collision wirh specific tiles and then turn of dynamic lightning on or off.... There is a range also...

To use something like that you have to put all the tiles in folders.... Because the code works with children nodes.... You can create different folders for different type of tiles... And then use the collsion method acvordingly....

Here is the link to download the age of epire clone game....
https://drive.google.com/file/d/...


I never tried this by myself but i assume that it might work... Just give it a try...
Check the collision for the terrain and then play the sound accordingly..
on collision of the player, If colliding tile/object is a children node of the folder metal then play the metaalic sound...
Or if it is a children of the folder named wood then play wood sound...
And so on....

Hope that helps...


Robo
Guest
Quote
2020-04-16 02:24:42

Yeah, thanks "just_in_case".
I got your code in the 'behavior_2D_RTS_Unit' and thought to implement pretty much the same thing by grouping tiles together in sections under separate folders and just use a single proximity check for each section to determine when the player is close to one section then to run a for-loop over the child nodes in that section only to determine when on top of a tile or not - else don't run any for-loops.

The way I would have checked for distance would be something like:

var moveto = ccbGetSceneNodeProperty(this.TargetNode, "Position");
var mepos = ccbGetSceneNodeProperty(this.ThisNode, "Position");
var tmp = mepos.substract(moveto);
var length = tmp.getLength();

I notice your code does much the same thing only differently:
once gotten player position then runs:
if (this.unit_pos.x-this.line_of_sight-50 < target_pos.x && this.unit_pos.x+this.line_of_sight+50 > target_pos.x && this.unit_pos.z-this.line_of_sight < target_pos.z && this.unit_pos.z+this.line_of_sight > target_pos.z);

I wonder which runs faster ?, or maybe not much of any difference.

I notice you check all 100 squares for distance checking every 3ms as shown in your AGEY ccb file. I am hoping I can get this to run only every like 100ms or more as less cpu intensive and group into 10 tiles at a time in each for-loop checks also.


just_in_case
Moderator
Quote
2020-05-04 05:28:19

Yes, that will be a good idea to use higher ms like 100 and more... I am thinking on working on the project again... Because age of empure clone always gives me so many hopes but untill i get a good shader to change rgb color of the texture according to team am letting it settle there in my hard drive.

Really wish to see new updates for the engine. Thats why am not developing anything yet with coppercube cause am waiting for an update.


Robo
Guest
Quote
2020-05-04 12:44:26

wrote:
Yes, that will be a good idea to use higher ms like 100 and more... I am thinking on working on the project again... Because age of empure clone always gives me so many hopes but untill i get a good shader to change rgb color of the texture according to team am letting it settle there in my hard drive.


Yes, your efforts in your game was nice - you should finish that and sell it when done.
- one method for your game might be to find the square in front of your player and then if you have them numbered such that their number is close to each other, just do a for loop over say 20 or 30 of them as needed rather than the whole lot each time.
- another idea is to have a list of equally distant key squares (like 10) that get searched each time (in a for loop) to find which is closest to the player and from the name of that square (use substring) lookup all the squares around that key square from that matching predefined array - so maybe a list of 10 also. Do that for all 10 key squares and you have covered all 100 that way without needing to run it for all 100 all the time.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Inter?ational" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact