ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperCube > Programming and Scripting
forum topic indicator Lifting of the fog...
person icon
luposian
Registered User
Quote
2023-08-23 04:08:36

Ok, we're in the home stretch, people! Well, at least as far as Stage 1. Now comes the next step... lifting the fog.

I don't imagine it would be that easy to gradually lift (fade away) the fog, as you're climbing the mountain, so I'd assume making it just vanish, once you get to the top of one of the mountains would be the chosen tactic.

I'm assuming all the mountains are the same height, so knowing the actual altitude at the plateau would be useful in knowing when to trigger the fog removal.

Question is... how would this be done?

person icon
just_in_case
Moderator
Quote
2023-08-23 05:47:39

well, it is easy to gradually lift the fog as you climb the mountain, I don't think you should use sudden removal of the fog as it won't look that good viusally.

You can easily acess the root scenenode property for "FogDensity" and based on the altitude of the player on the mountains you can decrease the "FogDensity"

just use this command.

 var root = ccbGetRootSceneNode();
ccbSetSceneNodeProperty(root,"FogDensity", your value here);


you can execute the above command in execute javascript action, whenever you need to edit the fog density, just change the "your value here" with actual fog value for the fog density.

Hope that helpsemoji icon_holy

person icon
luposian
Registered User
Quote
2023-08-23 08:57:39

wrote:
well, it is easy to gradually lift the fog as you climb the mountain, I don't think you should use sudden removal of the fog as it won't look that good viusally.

You can easily acess the root scenenode property for "FogDensity" and based on the altitude of the mountains you can decrease the "FogDensity"

just use this command.

 var root = ccbGetRootSceneNode();
ccbSetSceneNodeProperty(root,"FogDensity", your value here);


you can execute the above command in execute javascript action, whenever you need to edit the fog density, just change the "your value here" with actual fog value for the fog density.

Hope that helpsemoji icon_holy

Ok, this triggered a thought in my head... but the problem is, I sense that part of the height limiting behavior would somehow play into this code as well... because I need to know how high I'm going up the mountain to trigger the next decrease in fog density. The default is 10 (which actually is a little too short in actual game usage, but...), but I'm having trouble deciphering what code does what... and how much of it I actually need. And can I even use any of that code in immediate javascript execution mode (I made an earlier attempt and it didn't seem to work), vs behavior file mode (which works perfectly). emoji icon_hmpf

person icon
VP
Guest
Quote
2023-08-23 12:07:57

Use on proximity events to set markers for fog density changes to occur without coding - or search the forum for "get distance between two points" to code it, based on the character's perpendicular distance from a ground plane.

person icon
luposian
Registered User
Quote
2023-08-23 19:38:59

VP wrote:
Use on proximity events to set markers for fog density changes to occur without coding - or search the forum for "get distance between two points" to code it, based on the character's perpendicular distance from a ground plane.

How? Where? The mountains are just bumps in the terrain node. They're not physically different nodes. So, how would I do a proximity event for my character or the terrain itself? And, as for doing a forum search for "get distance between two points", it only lead me to this thread! Seriously! emoji icon_grin

person icon
sven
Registered User
Quote
2023-08-23 20:09:24

If there is no node ,you can always make one..and attach proximity on it. For example CUBE ( set collision off for it and put it inside the mountain )
Set proximity to a BOX mode.

If i have time i will look for this script -i have this script already made.

person icon
luposian
Registered User
Quote
2023-08-23 20:19:55

wrote:
If there is no node ,you can always make one..and attach proximity on it. For example CUBE ( set collision off for it and put it inside the mountain )
Set proximity to a BOX mode.

If i have time i will look for this script -i have this script already made.

But, if I want to be able to climb ANY mountain... there's like 6 or 9 of them. If I stacked, say, 3 cubes (one cube per step of fog dissipation) inside each mountain, that would be a total of 18-27 cubes I have to place! And I have to have them all numerically indentified... ugh! emoji icon_grin

person icon
sven
Registered User
Quote
2023-08-23 20:42:27

you need actually just one mountain Highest one to setup..
on proximity area can cover all the other mountains also.

i have script for this i send it tomorrow- but its good to practice with other methods as on proximity.

EDIT:
script:
https://drive.google.com/file/d/...

MaxHeight value if you put there higest point of the map then if player reaches it -fog will be 0
so to keep some fog in scene add some value to it.
On my map Higest point was 50 but in script i put 60 so there will be never zero fog.

person icon
Dieter
Guest
Quote
2023-08-23 21:52:19

Maybe I didn't get the point, but why don't you simply use the player altitude as fog density parameter? I mean, negatively, and not necessarily linear. You could have a density value for every foot above sea. This may be a curve, or even a cloud layer.

(Wow, did anybody every make a game in which you see the clouds from above, like a dry ice ocean?)

And re Distance, there may or may not be integrated functions that return a distance, however, you are always on the save side when you know how to implement it using the basics:

Distance between two points by 3D pytagoras:
distance= squareroot of ((xd*xd)+(yd*yd)+(zd*zd))
(xd is x distance...)

or in javascript and coppercube:

pos1=ccbGetSceneNodeProperty(node1,"PositionAbs");
pos2=ccbGetSceneNodeProperty(node2,"PositionAbs");
xd=pos1.x-pos2.x;
yd=pos1.y-pos2.y;
zd=pos1.z-pos2.z;
dist=Math.sqrt((xd*xd)+(yd*yd)+(zd*zd));


person icon
luposian
Registered User
Quote
2023-08-24 00:48:50

@Sven - It works perfectly! However... there's one teensy, tiny problem... the fog comes back as I climb down the mountain! Once you've climbed the mountain and the fog goes away, I want it to stay gone! emoji icon_grin

person icon
VP
Guest
Quote
2023-08-24 07:33:52

Sounds like it's already sorted with coding....

but, as for my comment, you don't need separate nodes for the mountains - you just needed a single on-proximity event, attached to a ground-plane.

IE: Make a plane, set position of plane to ground-level, stretch size across the entire ground, then just set on-proximity (cube, not sphere) to the height you want the fog to start lifting, use action: "on-leave" proximity, set fog density (value).

If you want several stages of fog-thinning (so it gets thinner, the higher he climbs), just use several on proximity-events attached to the same ground-plane - you can also use "on enter" proximity - to make the fog thicker again when he moves down the mountain.

person icon
luposian
Registered User
Quote
2023-08-24 08:15:43

Ok, the code Sven provided works perfectly. But I want to the fog to stay GONE, after you've reached the top of the mountain, so when you climb back down, the fog does NOT reappear.

person icon
VP
Guest
Quote
2023-08-24 08:20:53

Use the coding solution provided - it's probably a better solution.

...but just to explain how I use a single"on proximity" node to detect player-height (even with multiple terrain-mountains), I made a simple ccb file for you with no-coding...

https://veganpete.itch.io/reques...

Download the one called "fog-fade".

*You can use the same trick for playing a sound when the player jumps/falls/lands, when a car mounts a pavement/curb, to fade a spaceship sound out when it gets far away, to play a splash animation/sound when objects land in puddles: etc.

person icon
veganpete
Registered User
Quote
2023-08-24 09:18:10

Above example uses a single on-proximity node...climb any mountain to reduce fog-density, the higher you go. Fog density doesn't return when climbing back down.

person icon
luposian
Registered User
Quote
2023-08-24 09:26:07

wrote:
Above example uses a single on-proximity node...climb any mountain to reduce fog-density, the higher you go. Fog density doesn't return when climbing back down.

In as much as was possible for me to control that cardboard cutout of that rat creature ("Lupain"? Seriously?), I did notice it seemed that the fog, indeed, did not return, coming back down. But surely the same thing could be incorporated into the behavior file that Sven provided, which was much more gradual of a fog fade. I just need fog turned off when you reach the top. But how to make that happen?


Create reply:










 

  

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


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






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