- Home /
 
Simulating Water not working..
My problem is I have all of the physics ratio finished as in relating to the water level and what not.
PROBLEM: when I am "In" the water it freezes but unfreezes when I jump and am not "In" the water. Now how would you guys go about fixing this? (I can't use rigidbody on my controller so I have to rely on transform.position)
Here's the script:
 var water: Transform;
 var self: Transform;
 var x = 0;
 var ypos;
 var waterLevel;
 var bouyancy: float;
 function Update () {
  ypos = self.transform.position.y;
  waterLevel = water.transform.position.y;
    if(x == 1){
 
 
 var gravity = GetComponent(CharacterMotor).gravity;
 
 }
  if(x != 1){
     gravity = 20;
      }
   if(ypos == waterLevel)
                 {
       gravity = 1;
                 }
   if(ypos < (waterLevel - 1)){
             x =1;
             gravity = -4;
                         }
    if(ypos > waterLevel){
             x = 0;
             gravity = 20;
                         }
 
               }
Answer by Waz · Jul 04, 2011 at 12:34 PM
You're calculating this gravity value, then not doing anything with it (if I read it correctly, but the formatting is horrible, how can you read that?)
the gravity value is relevant to the character controller. Which the character controller I believe handles all or most all gravity calculations
But you haven't set it back! It's as if you're missing the final line:
  GetComponent(Character$$anonymous$$otor).gravity = gravity;
 
                 Your answer
 
             Follow this Question
Related Questions
How to animate Pro Water3 0 Answers
Caustic underwater effect 1 Answer
How do i make floating ship ? 0 Answers
Floating Character, Water3 1 Answer
Making realistic water 0 Answers