Dynamic Waterblocks, Is it possible?
by Jerry Moore · in Torque Game Engine · 03/15/2006 (8:37 am) · 3 replies
Is there a way of dynamically raising and lowering the waterblock through code ( to create waves that increase and decrease over time)? Any help would be appreciated.
About the author
#2
03/22/2006 (5:31 pm)
I was thinking it over and it should be possible in and I wrote code down below to try to control tides dynamically. The idea is that I want to create Tides (waterblock) that increase over time gradually enveloping the land or flooding it and then after while subsides (just like how real ocean increases when there is a high tide and decrease when there is a low tide.) I know that I can increase the size of the waterblock from typing it in the properties box in the game, but it never increases dynamically until I chang the value again in the properties box My main problem is I am not sure where to plug it in. There has to be some dynamic way of doing this. Help me please. Thanks.//==============================================================================
// Tide.cs
//
// This modules controls the ocean's tides
//
//=============================================================================
//
function Tide()
//-----------------------------------------------------------------------------
// This function controls high and low tide
//-----------------------------------------------------------------------------
{
%HighTide=10;
%LowTide =5;
%inc = 0.001;
%counter= %counter + %inc;
if (%counter < 1)
return;
if (%Tide = %HighTide)
%Tide=%Tide+1;
if (%Tide = %LowTide)
%Tide=%Tide-1;
$OceanHeight=$OceanHeight+%Tide;
%counter=0;
return($OceanHeight);
}
//
function Wave()
//----------------------------------------------------------------------------
//This function contols the speed and direction of the waves
//----------------------------------------------------------------------------
{
%inc = 0.001;
%counter= %counter + %inc;
if (%counter < 1)
return;
%S = 1;
for ( %S <= 20 ; $WaveSpeed =%S-10 ; %S++ )
//Tide in
if (%S > 0)
$WaveDir=30;
//Tide out
if (%S < 0)
$WaveDir=180;
%counter=0;
return($WaveSpeed);
}
function MoveOcean()
{
Tide();
Wave();
}
#3
04/17/2006 (7:19 am)
Looks interesting. I'll have a look into this for my own code. thanks
Torque Owner Funky Diver