Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Edgar_Herrera, VoroneTZ, Akow), 968 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Gravity question. #319675
04/16/10 17:30
04/16/10 17:30
Joined: Oct 2009
Posts: 60
T
Tman Offline OP
Junior Member
Tman  Offline OP
Junior Member
T

Joined: Oct 2009
Posts: 60
If anyone knows this please reply. I was wondering how does the physics system work in Game Studio, and what I mean is then when I run my character off the edge of the world he floats up like he is in space but when I put him over land gravity pulls him down to the. Is there a way to set gravity to keep pulling him down even when he is not over anything or is it a GS thing.

Re: Gravity question. [Re: Tman] #319677
04/16/10 17:42
04/16/10 17:42
Joined: Oct 2009
Posts: 90
WickWoody Offline
Junior Member
WickWoody  Offline
Junior Member

Joined: Oct 2009
Posts: 90

Re: Gravity question. [Re: Tman] #319679
04/16/10 17:42
04/16/10 17:42
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
What are you using? Are you using templates? This section is normally for those who write their own code; if you do, it would be helpful to know what you're actually doing.

Jibb


Formerly known as JulzMighty.
I made KarBOOM!
Re: Gravity question. [Re: JibbSmart] #319680
04/16/10 17:49
04/16/10 17:49
Joined: Oct 2009
Posts: 60
T
Tman Offline OP
Junior Member
Tman  Offline OP
Junior Member
T

Joined: Oct 2009
Posts: 60
Yeah I write my own stuff, here is what is am doing:
Code:
var nc_gravity = 1;


/****************************************
*The sword is in
*this will handle all movement and other
*actions with the sword being in
****************************************/
function handle_SwordIn()
{

   VECTOR vFeet;
   vec_for_min(vFeet,me); // vFeet.z = distance from player origin to lowest vertex
	vec_set(tempV,my.x);
	tempV.z -=1000;
	
	
   while(1)
   {  
   
   
     
      //set the move friction to stick to the ground
        move_friction = 0.1;
			//move the entity forward
			var distance = 5 * (key_cuu + key_cud)* time_step;
			distance = sign(distance)* (abs(distance) + 0.5 * dist_down);
		 c_move(me,vector(distance,0,speed_down),vector(0,0,-dist_down),USE_BOX|IGNORE_PASSABLE|IGNORE_ME| GLIDE |USE_POLYGON);
		 	//rotate player with the left and right keys
			my.pan += (key_cul-key_cur)*5*  time_step;
		
     
      
		// adjust entity to the ground height, using a downwards trace
		c_trace(my.x,tempV,IGNORE_PASSABLE|IGNORE_ME|USE_POLYGON |SCAN_TEXTURE|GLIDE );
	  dist_down = my.z + vFeet.z - hit.z; // always place player's feet on the ground
		 
		//this will put the player on the ground and clamp him
     dist_down = clamp(dist_down,-1,100);
		//if the dist is greater than zero
	   if((dist_down > -1))
		{
		  //clamp the player to the ground and accelerate at a down speed
		  dist_down = clamp(dist_down,-1,accelerate(speed_down ,-nc_gravity *  time_step,0));
		 
		}
		else
	   {
	   	//do the speed down to equal 0 so that he snaps to the ground
	   	speed_down = -1;
	   	if((dist_down + speed_down)> -1)
	   	{
	   		speed_down = - dist_down + -1 ;
	      }
	      if(key_space == 1)
	      {
	      	jump_target = jump_height ;//* time_step
	     
	     	   
	      }
       }
       if(jump_target > 0)
       {
       	speed_down = (sqrt((jump_target)* nc_gravity))*time_step;
         	
       	jump_target -= speed_down ;
        }
  
	 
      //default state
		if(my.STATE == 0)
		{
			my.ANIMATION += time_step;
			my.ANIMATION %= 100;
		   ent_animate(me,"idleSWA",my.ANIMATION,ANM_CYCLE);
		  
			
		}
		//the run state without the sword in hand
		if(my.STATE ==1)
		{
			//animate the player
			my.ANIMATION += run_animation_speed  * time_step;
			my.ANIMATION %= 100;
			ent_animate(me,"runWS",my.ANIMATION,ANM_CYCLE);
			
					
		}
		//pressing the move key to make him run with out the sword
		//changing his state
		if((key_cuu) && !key_cud && my.STATE == 0 )
		{
		my.ANIMATION = 0;
		  ent_blend(my.STATE = 1,0,50) ;


		}
		else if((!key_cuu)&& key_cud ==1 && my.STATE == 0)
		{
			my.ANIMATION = 0;
			ent_blend(my.STATE = 1 ,0,50);
		
		}
		
		else if((!key_cuu)&& !key_cud && my.STATE == 1 && my.ANIMATION > 70)
		{
		  my.ANIMATION = 0;
		  ent_blend(my.STATE = 0, 0,100);
		  		
		}	
	/********************************************
	*put the sword away                         *
	********************************************/
		if(my.STATE == 5)
		{
			my.ANIMATION += 5 * time_step;
			ent_animate(me,"putSWA",my.ANIMATION,NULL);
			if(my.ANIMATION > 100)
			{
			 ent_blend(my.STATE = 0,0,50);
			}
			
		}
			if(my.STATE ==7)
		{
			my.ANIMATION += 50 * time_step;
			ent_animate(me,"jump",my.ANIMATION, 0);
			ent_blend("hang",20,5);
		}
		if(my.STATE == 9)
		{
			my.ANIMATION += 15 * time_step;
		   ent_animate(me,"land",my.ANIMATION,0);
		   if(my.ANIMATION > 0)
		   {
		     ent_blend(my.STATE = 0,25,50);
		   }
		}
		if(my.STATE == 11)
		{
			my.ANIMATION += 15 * time_step;
		   ent_animate(me,"land",my.ANIMATION,0);
		   if(my.ANIMATION > 100)
		   {
		     ent_blend(my.STATE = 1,50,70);
		   }
		}
		if(my.STATE == 20)
	   {
		var slide = 5 * (key_r - key_l) * time_step;
     		c_move(me,vector(0,slide,0),nullvector, IGNORE_ME|IGNORE_PASSABLE|GLIDE);
		my.ANIMATION += 10 * time_step; 
		ent_animate(me,"ledgeShimy",my.ANIMATION,ANM_CYCLE);
	   }
	
		//when your idle is sword in hand 
		//and you want to put it away
		if((key_p == 1) && my.STATE == 4)
		{
			my.ANIMATION = 1;
			my.STATE = 5;
			
		}
	//now you have put the sword away
	//go back to original state and start over again
	if((my.STATE == 5) && key_cuu == 1)
	{
			my.ANIMATION = 1;
    		my.STATE = 1;
   }
   if(my.STATE == 0 && key_space == 1 && !reached_height)
   {
   	my.ANIMATION = 0;
		my.STATE = 7;
	   reached_height = 1;
	  
   }
    
   if(my.STATE == 7 && dist_down ==-1)
	{
		 my.ANIMATION = 0;
	    my.STATE = 9;
	    reached_height = 0;	
	}
	else if(my.STATE == 1 && key_space == 1 && key_cuu == 1 && !reached_height)
   {
   	my.ANIMATION = 0;
		my.STATE = 7;
			reached_height = 1;
   }
   
   if(my.STATE == 7 && dist_down ==-1 && key_cuu == 1)
	{
		 my.ANIMATION = 0;
	    my.STATE = 7;
	    reached_height = 0;	
   }
 
wait(1);
}

}


This is code for my player with the sword in the sheath and with gravity set, I read the manuals for lite-c studied doc and everything. I looked at ph_setgravity and my player just stays in one place and according to the manual was told not to put that on a moving character, but just wondering how that works?

Last edited by Tman; 04/16/10 17:52.
Re: Gravity question. [Re: Tman] #319683
04/16/10 18:32
04/16/10 18:32
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
You should get the result of the trace -- that's the distance between the from-vector to the to-vector (like so: result = c_trace...; although result is automatically set anyway as far as I know).

If result == 0, nothing was hit, so the player should fall.

Your problem is that nothing is being hit, so the hit.z isn't being set.

I hope that makes sense.

Jibb


Formerly known as JulzMighty.
I made KarBOOM!
Re: Gravity question. [Re: JibbSmart] #319908
04/18/10 18:49
04/18/10 18:49
Joined: Oct 2009
Posts: 60
T
Tman Offline OP
Junior Member
Tman  Offline OP
Junior Member
T

Joined: Oct 2009
Posts: 60
That makes sense. I will try that.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1