|
PhysX
#336175
08/02/10 06:59
08/02/10 06:59
|
Joined: May 2009
Posts: 5,377 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,377
Caucasus
|
I tried to make physic controlled player with PhysX, everything looks working great, but when I push physic objects (box for example) to the corner, object goes through the player (that is bug I guess). Here is the code I've made:
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
#include <default.c>
#include <ackphysx.h>
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
VECTOR dist;
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
var hero_move_speed = 8;
var hero_turn_speed = 10;
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
function main()
{
physX_open();
fps_max = 60;
level_load("1.WMB");
wait(1);
}
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
function camera_set()
{
camera.tilt = -90;
camera.pan = my.pan;
vec_set(camera.x,vector(my.x,my.y,my.z + 800));
}
function handle_gravity()
{
result = c_trace(my.x,vector(my.x,my.y,my.z - 1000),IGNORE_MODELS|USE_BOX);
if(result > 10)
{
accelerate(dist.z,-10,1);
}
else
{
dist.z = -(result/1.2)+4;
dist.z = clamp(dist.z,-4,4);
}
}
function handle_movement()
{
if(key_w)
{
dist.x = hero_move_speed * time_step;
}
else
{
if(key_s == 0)
{
dist.x = 0;
}
}
if(key_s)
{
dist.x = -hero_move_speed * time_step;
}
else
{
if(key_w == 0)
{
dist.x = 0;
}
}
if(key_a)
{
dist.y = hero_move_speed * time_step;
}
else
{
if(key_d == 0)
{
dist.y = 0;
}
}
if(key_d)
{
dist.y = -hero_move_speed * time_step;
}
else
{
if(key_a == 0)
{
dist.y = 0;
}
}
my.pan -= hero_turn_speed * mouse_force.x * time_step;
vec_rotate(dist,my.pan);
}
action hero()
{
player = my;
pXent_settype(me,PH_CHAR,PH_BOX);
while(1)
{
handle_gravity();
handle_movement();
pXent_movechar(me,dist,my.pan,0);
camera_set();
wait(1);
}
}
action physX_box()
{
pXent_settype(my,PH_RIGID,PH_BOX);
pXent_setmass(my,5);
pXent_setfriction(my,5);
pXent_setdamping (my,50,50);
pXent_setelasticity(my,0);
}
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
PANEL* gui =
{
layer = 1;
digits(10,0,4,"Arial#24bi",1,player.pan);
flags = SHOW;
}
|
|
|
Re: PhysX
[Re: jcl]
#338698
08/20/10 17:37
08/20/10 17:37
|
Joined: Oct 2007
Posts: 40 Switzerland
Nikozu86
Newbie
|
Newbie
Joined: Oct 2007
Posts: 40
Switzerland
|
Helo, is there a example for a simple plane using PhysX?? controls: W,S = tilt A,D, = roll Y = soft Brake X = speed up
i know how to do it with A7, but the new pX-stuff gives me an headache :-(
That`s all i need.
NO NEED ANYMORE! I Made it! :-)
Last edited by Nikozu86; 08/20/10 20:43.
|
|
|
Re: PhysX
[Re: 3run]
#338873
08/22/10 10:35
08/22/10 10:35
|
Joined: Aug 2009
Posts: 1,438 Spain
painkiller
Serious User
|
Serious User
Joined: Aug 2009
Posts: 1,438
Spain
|
I had the same problem as you when I tried to use PhysX for my player movement, I couldn't get him go through stairs
3D Gamestudio A8 Pro AMD FX 8350 4.00 Ghz 16GB RAM Gigabyte GeForce GTX 960 4GB
|
|
|
Re: PhysX
[Re: painkiller]
#340166
09/01/10 15:35
09/01/10 15:35
|
Joined: Feb 2010
Posts: 886
Random
User
|
User
Joined: Feb 2010
Posts: 886
|
Maby you just make the player walk over smaler physical objeckts, becose its anyway not realistig that the little man pushes 5 times bigger things then himself...
|
|
|
|