c_move in negative area

Posted By: IngoP

c_move in negative area - 10/07/11 12:54

Hello,
i have a problem with the c_move. I hope, someone could help me.
if I say in the script c_move with positive x or y vectors, it works, but if i use -1 in x or y it don't moves or it duplicates it and there are 2 or 3 models...
(dist_down is the distance between the model and the landscape, but it seems to work correct)
Here's the code that works (in while loop):
Code:
c_move(me,vector(1,0,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); 
c_move(me,vector(0,1,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE);


don't works:
Code:
c_move(me,vector(-1,0,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); 
c_move(me,vector(0,-1,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE);



best regards
IngoP
Posted By: Pappenheimer

Re: c_move in negative area - 10/07/11 14:18

What do you mean by 'duplicate'? Can't believe that it doesn't work because there are probably a lot of projects with a movement code similar to this, where I never heard of that it doesn't work:
Code:
c_move(me,vector(key_w - key_s,0,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE);


Posted By: IngoP

Re: c_move in negative area - 10/11/11 09:45

ok, hmm than I have a problem with my function... (the logic works if I proof it with printf at some points) I searched over 2 weeks now, could you help me please? The Model is on 0,0 positiv works, but negatives, he stands still.
Here's my code:

Code:
var hausx= -150;
var hausy = -400;
var anzahlwasser = 1;
var wasserx = 200;
var wassery = 300;
var anzahlwasserschl = 0;
var anzahlwasserschl2 = 0;
var zielx1 = 0;
var ziely1 = 0;
var zielx2 = 0;
var ziely2 = 0;

action player_walk()
{ 
// if necessary, adjust the bounding box to give the entity 'floor room' (see remarks) 
// my.min_z *= 0.5;

   var speed_down = 0;   // downward speed by gravity
   var anim_percent = 0; // animation percentage
   VECTOR vFeet;
   vec_for_min(vFeet,me); // vFeet.z = distance from player origin to lowest vertex
	var dist_ahead = 5*time_step;
   while (1)
   {
// rotate the player using the [A] and [D] keys      
      //my.pan += 5*(key_a-key_d)*time_step; 
      my.pan = 0;

// determine the ground distance by a downwards trace
      var dist_down; 
      if (c_trace(my.x,vector(my.x,my.y,my.z-5000),IGNORE_ME | IGNORE_PASSABLE | USE_BOX) > 0)
         dist_down = my.z + vFeet.z - target.z; // get distance between player's feet and the ground
      else
         dist_down = 0;

// apply gravity when the player is in the air
      if (dist_down > 0)  // above floor, fall down with increasing speed
         dist_down = clamp(dist_down,0,accelerate(speed_down,5,0.1));
      else                // on or below floor, set downward speed to zero
         speed_down = 0;

// move the player using the [W] and [S] keys      
      //var dist_ahead = 5*(key_w-key_s)*time_step;
      var dist_ahead = 5*time_step;
      dist_ahead = sign(dist_ahead)*(abs(dist_ahead) + 0.5*dist_down); // adapt the speed on slopes
  

  
      if(anzahlwasser > 0){
		zielx1 = wasserx;
		ziely1 = wassery;
		
		if (anzahlwasserschl == 0)
		{
      if(me.x < zielx1)
      {
     		c_move(me,vector(1,0,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); // move the player
      }
      
      if(me.x > zielx1)
      {
      	c_move(me,vector(-1,0,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); // move the player
      }
      
      if(me.y < ziely1){
      	c_move(me,vector(0,1,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); // move the player
      }
      
      if(me.y > ziely1){
      	c_move(me,vector(0,-1,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); // move the player
      }
      }
     
		if(me.x == zielx1 && me.y == ziely1){
			
		anzahlwasserschl2 = 1;
		}
		
		if(anzahlwasserschl2 == 1){
		anzahlwasserschl = 1;
		zielx2 = hausx;
		ziely2 = hausy;

   	if(me.x < zielx2)
      {
     		c_move(me,vector(1,0,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); // move the player
      }
      
      if(me.x > zielx2)
      {
      	c_move(me,vector(0,0,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); // move the player
      }
      
      if(me.y < ziely2){
      	c_move(me,vector(0,1,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); // move the player
      }
      
      if(me.y > ziely2){
      	c_move(me,vector(0,0,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); // move the player
      }
      
		if(me.x == zielx2 && me.y == ziely2){
			printf("fertig:",(double)anzahlwasser);
			anzahlwasser = anzahlwasser - 1;	
			anzahlwasserschl = 0;
			anzahlwasserschl2 = 0;			
		}

		}

	}



	                    
      //c_move(me,vector(100,0,0),vector(0,0,0),IGNORE_PASSABLE | GLIDE); // move the player
// animate the player according to its moved distance
      if (dist_ahead != 0) // player is moving ahead
      {
         anim_percent += 1.3*dist_ahead; // 1.3 = walk cycle percentage per quant
         ent_animate(me,"walk",anim_percent,ANM_CYCLE); // play the "walk" animation
      }
      else // player stands still
      { 
         anim_percent += 5*time_step; 
         ent_animate(me,"stand",anim_percent,ANM_CYCLE); // play the "stand" animation
      }
      wait(1);
   }
}


Posted By: FlorianP

Re: c_move in negative area - 10/11/11 10:24

I dont get what u mean with duplicate and what ur script is supposed to do as f.i. dist_ahead is never used - but one problem lies probably here:

Code:
if(me.x < zielx1)
      {
     		c_move(me,vector(1,0,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); // move the player
      }
      
      if(me.x > zielx1)
      {
      	c_move(me,vector(-1,0,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); // move the player
      }



lets say zielx1 is 0.5 and my.x is 0.
Then the entity is moved to my.x 1 - my.x is now > zielx1, so the entity is moved back to 0 (while 'falling' twice)
Posted By: IngoP

Re: c_move in negative area - 10/11/11 15:00

I thought about it, yes, it could be a Problem, but me.x is 0 and zielx1 is -150. I tested it now without any if, but this c_move (negative) don't works:

Code:
c_move(me,vector(-1,0,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); // move the player


While this is working:
Code:
c_move(me,vector(1,0,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); // move the player


only difference is the minus, (the model should walk without using keys)
Posted By: IngoP

Re: c_move in negative area - 11/01/11 17:43

could no one help me?
Posted By: Superku

Re: c_move in negative area - 11/01/11 18:13

Upload a small demo.
© 2024 lite-C Forums