Game Development Community

OnEnterLiquid never called - mWaterCoverage always zero

by Orion Elenzil · in Torque Game Engine · 02/14/2006 (2:01 pm) · 10 replies

Hi All -

Anybody have an idea why mWaterCoverage would always be zero ?
This doesn't seem to be the same as this issue, since even when only half-submerged i still get zero.

Splashes don't occur when the player falls in or moves.

We have no terrain, could that be playing in ?

The underwater rendering (foggy) is correct, so some part of the engine knows we're under there.


tia,
Orion

#1
02/14/2006 (2:19 pm)
Correct me if I'm wrong Orion, but isn't the fog filter just a z-coordinated variable set in the sky object? If you remove the water, the fog should be visible.

Edit: Which is not a solution to your problem, but I just want to point out that just because the fog is visible, doesn't mean the engine knows that you're underwater.
#2
02/14/2006 (2:34 pm)
Hi Stefan, thanks for replying.

- i don't think the water fog is a simple camera Z check,
because the fog turns off if i fly out either the side or bottom of the waterblock.
#3
02/14/2006 (11:55 pm)
What is the kind of datablock used for the object which enter into the water :

itemdata ?
vehicle ?


Enter liquid means : you are in an interior or shape or terrains and you enter into the water.

Is your environment well defined as interior, terrains or shape and water as water ( in the terrain editor ) =>
do you have used a "water block" in the editor => in a one of the cs file you have to find : WaterBlock(...) {...}

:)
#4
02/15/2006 (9:33 am)
Hi Philippe,

This is regarding the player, who's datablock is type PlayerData.

The environment is composed of InteriorInstance's,
and the water is of type WaterBlock.

Here's the water's datablock, in case anyone spots something obviously wrong:

thanks,
orion

new WaterBlock(Water) {
      position = "-416 -544 -99.4";
      rotation = "1 0 0 0";
      scale = "1024 1024 100";
      UseDepthMask = "1";
      surfaceTexture = "~/data/worlds/water/water4";
      ShoreTexture = "~/data/worlds/water/water4";
      envMapOverTexture = "~/data/worlds/water/water4";
      specularMaskTex = "~/data/worlds/water/specmask";
      liquidType = "StagnantWater";
      density = "1";
      viscosity = "10";
      waveMagnitude = "0.2";
      surfaceOpacity = "0.6";
      envMapIntensity = "0.5";
      TessSurface = "50";
      TessShore = "15";
      SurfaceParallax = "0.9";
      FlowAngle = "0";
      FlowRate = "0.01";
      DistortGridScale = "0.01";
      DistortMag = "0.005";
      DistortTime = "0.9";
      ShoreDepth = "6";
      DepthGradient = "1";
      MinAlpha = "0.1";
      MaxAlpha = "1";
      removeWetEdges = "1";
      specularColor = "0.000000 0.100000 0.200000 1.000000";
      specularPower = "50";
      envMapTexture = "~/data/worlds/skies/01-10/01-10_0007";
   };
#5
02/15/2006 (10:51 am)
Could you add to the post the code of the function "playerdata"::OnEnterLiquid ?

Is the other values received by this function are correct ?

Could put an echo for all the parameters of the functions in order to check if at the first call of the function the values are correctly set ?


function playerdata::onEnterLiquid(%this, %obj, %coverage, %type)
{
echo(%this,%obj,%coverage, %type)
....
}

start torque.exe with the option -console in order to get the echo into the console window.
#6
02/15/2006 (10:56 am)
Hi Philippe, thanks for replying.

The problem is actually further up the chain in the engine, in Player::updateMove().

This block of code never executes because mWaterCoverage is always zero:
if(!inLiquid && mWaterCoverage != 0.0f) {
         Con::executef(mDataBlock,4,"onEnterLiquid",scriptThis(), Con::getFloatArg(mWaterCoverage), Con::getIntArg(mLiquidType));
         inLiquid = true;
      }

.. It's not super critical to my project now,
so i haven't tracked it down more than this, but eventually i'll have to go see why mWaterCoverage is always zero. I was hoping it was a stupid mistake in the water datablock..
#7
02/15/2006 (11:51 am)
Ok , but just a last point

function playerdata::onEnterLiquid(%this, %obj, %coverage, %type)
{
echo(%this,%obj,%coverage, %type)
....
}

This function is called by torque engine in a script file.You have to use a script not C++ code.

I think that the problem is there . In one of the .cs file you have to find the function .

This script function is triggerred automatically by torque engine when player will enter into liquid.
#8
02/15/2006 (11:54 am)
Hi, thanks again,
i guess i should have been more explicit.

Yes, you are correct, my onEnterLiquid() script function is never being called.
However, the *reason* it's never being called is because the engine code which calls it is never executing,
and the reason for that is that the engine variable "mWaterCoverage" is always zero,
and the reason for that is... what i'd like to find out. :D
#9
02/15/2006 (1:34 pm)
But just for the fun a last point :

take care the test is the folowing :

if (!isGhost()) {
// Vehicle Dismount
if(move->trigger[2] && isMounted())
Con::executef(mDataBlock,2,"doDismount",scriptThis());

if(!inLiquid && mWaterCoverage != 0.0f) {
Con::executef(mDataBlock,4,"onEnterLiquid",scriptThis(), Con::getFloatArg(mWaterCoverage), Con::getIntArg(mLiquidType));
inLiquid = true;
}
else if(inLiquid && mWaterCoverage == 0.0f) {
Con::executef(mDataBlock,3,"onLeaveLiquid",scriptThis(), Con::getIntArg(mLiquidType));
inLiquid = false;
}
}

The first condition is ! isGhost(). But i don't know what does it means ...

Are sure that your script function is not called at least one time. Because if you have a look on the test . When the player enter in the liquid the function in the scripts is trigged and after when the player leave the liquid an function in the script is trigged (see the variable inLiquid ) .
It seems that betwen the enter and the leave the functions in the script are not called. It means that the function enterliquid is called only one time . And when the player is in the liquid any function in the script are called . Only when the player leaves the liquid the function leaveliquid is called in the script.

May be I am wrong.
Sorry to repost but I am very interested by the resolution of your issue (because it will be mine in few days ...)

:)
#10
02/15/2006 (1:42 pm)
LOL, thank you tons for taking so much time on this Philippe,
but i think i'm actually right when i say the root of the problem is that mWaterCoverage is always zero for me.

since it's always zero, this line never evaluates true:
if(!inLiquid && mWaterCoverage != 0.0f) {

and so the following call to onEnterLiquid is never made.

the IsGhost thing determines whether the object is server-side or client-side.
isGhost() = true if and only if it's a client-side object.


you probably won't have this problem,
as far as i know this isn't a common problem.
i'm pretty sure it's just something we've messed up somehow..