CRE8OR - game maker for anim8or |
||
|
WATER IN GAMES
You'll need to update Cre8or in Version 0.075a in order to run this correctly. The main drawback is that there is no transparency in Cre8or currently. However, it is a feature "soon to be." Let's assume you have some terrain that has uniform. The most important part is that water is everywhere, where a certain "depth" is a smaller than a threshold value. This is what none uniform water looks like. This is a bit more complicated and will not be demostrated in this tutorial:
Below is the type of water that we'll be using in this tutorial: notice that water is everywhere where the depth is a certain value.
It is important that you do not have parts of your level beneath the water's depth, which is not in water. I.E. Don't have "dry" underground caves beneath the water level. Because we'll asume that water is always at a certain "depth." Our coodrninate system is the same as anim8or's and most game coords, Z is forward/back, Y is up/down, and X is left/right.
So let's review what we expect: Basically there'll be two states, in water, out of water. Once the water level reaches chest value the player will switch to swimming animation. If in swimming mode and water level reaches slighly less than chest value then switch to standing mode. *Note: Remeber that when any bones are rotated, the physical sphere is still not rotated so collision will most likely be off; this will be handled later. How do we know if the object is below the water surface? If the objects "Y" position is larger than the water's Y Position than it is above. Else, it is below.
The easiest way to do this is "if in water mode" then apply a upward force, thus opposing the downward gravitational force. Ok so let's turn this explanation of a theory into applicable means; let me show you how it works. Go to scene01 and add the "Initiation" event. Now add a pice of code as shown This adds a new global varaible and sets it to "0.0" Now go to the "Water" entity
Now add another piece of code: This will make sure that the "water_level" variable is at the same height of Water Plane Object. This way you can more the Water object around in scene mode and not have to worry about changing "water_level"
Now things will get a little bit messy so try to hang on. Go to "Alien_Lizard"
Add a "IF" action and set the text to be: "get_position().y > water_level" Add the brackets "{..." "...}" and the "Else"
Move/Drag the "Stand Straight" into the first brackets:
Now that we know if the lizard is below the water, let us add some under water effects like, different camer, less gravity and more damping. Now add the upward force, the exact value is hard to fine, I found 250 to be a good value in this case: Now let's make sure the camera doesn't try to do anything silly:
Since we set the height and auto-height values for under water, we'll have to reset it for above water:
If you RUN it then you walk in the water your Idle animation chnages as well as the camera. Copy this action (Select, Ctrl+C): Do the exact same thing in the <RIGHT> keyboard event. Go to the <UP> Event and add it as shown: Add an "Else" Now copy the "Move Forward" action and paste it at the bottom. Then double click it:
RECOPY the "If get_postion...."
Now go to the <CTRL> event paste it there too: Double click it and change the text to the following: Add a upward force action, I found 900 to be a good value:
Underneath that if add a Upward Force, but this time use a Negative value so it pushes the object down, back under water.
|
|
Copyrights (C) 2007 Keith Tabert |
||