Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by M_D. 04/26/24 20:22
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (M_D, AndrewAMD, Quad, Ayumi), 806 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
PhysX movement #387299
11/16/11 22:24
11/16/11 22:24
Joined: Dec 2009
Posts: 53
Vyshess Offline OP
Junior Member
Vyshess  Offline OP
Junior Member

Joined: Dec 2009
Posts: 53
Hi @ all!

I started my next game and want to use the physic-engine.
everything works good except the player movement.
at first I was giving the player a box collision but that doesn`t works because, by running the skript, the player disappears suddenly or falls through the test-level(a hollow block),not sure what exactly happens.
So I was trying the capsule collision.at first it looks good.I see the player and can walk around..but there is something strange. I set the foots of the player exactly on the ground but if I push one of the movement-keys, the player model is suddenly a bit over the ground. apart from that the movement works very good.
thx for help laugh

my player-code:
Code:
action hero()
{
	var anim_percentage;

	pXent_settype(my, PH_CHAR, PH_CAPSULE); 

	set(my,SHADOW);
	wait(1);
  
	
	my.emask |= ENABLE_SCAN; // make the player sensitive to scanning
	player = my; // I'm the player
	
	
	while(players_health > 0)
	{
	
		//player movement//
       movement_speed.x = 10 * (key_cuu - key_cud) * time_step; // move the player using "cuu" and "cud"
	movement_speed.y = 10 * (key_cul - key_cur) * time_step; // move the player using "cur" and "cul"

       pXent_movechar(me, movement_speed, NULL, 0);
		///////////////////
		
		//player animation//
		if(key_cuu || key_cud)
		{
			if(movement_speed.x > 0){my.pan = 0;} // turn player to right
			if(movement_speed.x < 0){my.pan = 180;} // turn player to left
			anim_percentage += 7 * time_step;
			ent_animate(my, "walk", anim_percentage, ANM_CYCLE); // play the "walk" animation			
		}   
		
		if(key_cur || key_cul)
		{
			if(movement_speed.y > 0){my.pan = 90;} // turn player to right
			if(movement_speed.y < 0){my.pan = -90;} // turn player to left
			anim_percentage += 7 * time_step;
			ent_animate(my, "walk", anim_percentage, ANM_CYCLE); // play the "walk" animation			
		}   
		
		
		if (key_cuu + key_cud + key_cur + key_cul == 0) // none of the movement keys are pressed?
		{
			anim_percentage += 1.2 * time_step;
			ent_animate(my, "idle", anim_percentage, ANM_CYCLE); // play the "stand" animation
		}
		/////////////////////
	   
		on_l = plant_bomb;
		
		
		
	wait(1);
   }
}




A8 Commercial
A5 Standart
---------------
created games: - Bomber Maniacs
Re: PhysX movement [Re: Vyshess] #387320
11/17/11 09:29
11/17/11 09:29
Joined: Jun 2006
Posts: 379
Flevoland, 5 meters under wate...
Roel Offline
Senior Member
Roel  Offline
Senior Member

Joined: Jun 2006
Posts: 379
Flevoland, 5 meters under wate...
it might be possible that the capsule is bigger than your model.
You can overcome this by scaling your model down, call phent settype, and then scale it back.


Check out the throwing game here: The throwing game
Re: PhysX movement [Re: Roel] #387404
11/18/11 09:19
11/18/11 09:19
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
At the beginning of the function place "c_updatehull(me, 1);".
This should be sufficient to set the collision capsule to the size of the player.
A seldom but possible reason could be that a vertex of the model is placed beneath the model's feet.
Maybe, you can correct the height of the model with setting the min_z value manually, as well.

Re: PhysX movement [Re: Pappenheimer] #387452
11/18/11 20:26
11/18/11 20:26
Joined: Dec 2009
Posts: 53
Vyshess Offline OP
Junior Member
Vyshess  Offline OP
Junior Member

Joined: Dec 2009
Posts: 53
Thanks guys! Problem solved!!


A8 Commercial
A5 Standart
---------------
created games: - Bomber Maniacs
Re: PhysX movement [Re: Vyshess] #387461
11/18/11 23:00
11/18/11 23:00
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Could you please share your experience?


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: PhysX movement [Re: 3run] #387493
11/19/11 19:15
11/19/11 19:15
Joined: Dec 2009
Posts: 53
Vyshess Offline OP
Junior Member
Vyshess  Offline OP
Junior Member

Joined: Dec 2009
Posts: 53
@ 3run: oh sure! i forgot to post the answer, sorry ^^

i used Roal`s advice and it works very well!

Code:
action hero()
{
	my.scale_z = 0.1; //makes me smaller for a smaller hull

	pXent_settype(my, PH_CHAR, PH_CAPSULE); 

        my.scale_z = 1.0; //get back my original size
	...
}



Last edited by Vyshess; 11/19/11 19:18.

A8 Commercial
A5 Standart
---------------
created games: - Bomber Maniacs
Re: PhysX movement [Re: Vyshess] #388055
11/27/11 18:12
11/27/11 18:12
Joined: Dec 2009
Posts: 53
Vyshess Offline OP
Junior Member
Vyshess  Offline OP
Junior Member

Joined: Dec 2009
Posts: 53
hi! i had another problem!
can someone tell me how to use "pXent_addexplosion" correctly?
my player can place bombs. and this bombs should be blow away a box. i give the box this action:
Code:
action ph_box() // simple physics-based box
{
pXent_settype(my, PH_RIGID, PH_BOX); // this entity behaves like a box	
}



and the bomb has this function:
Code:
function bomb_behavior()
{

VECTOR bomb_pos;

	while(explo_time > bomb_wait_time) //after some seconds, the bomb explode
	{

		explo_time -= time_step/16;

		 pXent_settype(my, PH_RIGID, PH_SPHERE); // this entity behaves like a ball
	 	 pXent_setfriction(my, 100); 
  	 	 pXent_setelasticity(my, 10);
	 	 pXent_setdamping(my, 100,40);
		

		bomb_pos.x = my.x; //get the actually position of the bomb
		bomb_pos.y = my.y;
		bomb_pos.z = my.z;
		... //the rest of the code (explosion anim etc.)
	wait(1);
	}

pXent_addexplosion( my, bomb_pos, 1000,500); //values ok???
wait(-2);

ent_remove(my);
}



i spend some hours with that addexplosion and the values but it doesn`t work.the box doesn`t move. sometimes the box disappears or flys to another dimension, not sure what happend there.


A8 Commercial
A5 Standart
---------------
created games: - Bomber Maniacs
Re: PhysX movement [Re: Vyshess] #388056
11/27/11 18:32
11/27/11 18:32
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
The values look right for my taste, except that 1000 as force parameter is very high... try to build a testcase with a room, the box and the possibility to place a bomb, upload it and we can have our hands on it.

Re: PhysX movement [Re: HeelX] #388115
11/28/11 14:37
11/28/11 14:37
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Its tooo much.
My explsoion vars for a nade:
pXent_addexplosion(me,nullvector,200,300);

Last edited by Ch40zzC0d3r; 11/28/11 14:37.
Re: PhysX movement [Re: Ch40zzC0d3r] #388152
11/28/11 19:10
11/28/11 19:10
Joined: Dec 2009
Posts: 53
Vyshess Offline OP
Junior Member
Vyshess  Offline OP
Junior Member

Joined: Dec 2009
Posts: 53
i know that 1000 is too much. in my desperation, i was trying some crazy values.
i set the force to 10 to see whats going on. the bomb flys like a rocket to the sky...okay maybe i misunderstand the "VECTOR*vPos" part.
so i replaced "bomb_pos" with "nullvector". and now it seems that the bomb is hit by an explosion an flys to a random direction. but the box is still uneffected...even by a radius with 2000!


A8 Commercial
A5 Standart
---------------
created games: - Bomber Maniacs
Page 1 of 3 1 2 3

Moderated by  HeelX, Spirit 

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