Physics Problem

Posted By: bk9iq

Physics Problem - 07/13/10 23:45

Hello all,
I was trying to get a physics interaction between my character and a ball in the level such that when the player comes close to the ball, he pushes it in the direction it is supposed to move..
I am using this code but when I am coming close, the ball is not moving at all
Quote:

ENTITY* ball;

function physics_ball()
{

ball = ent_create ("ball.mdl", vector(-400, 0, 100), NULL); // create the ball
c_setminmax(ball);
pXent_settype (ball, PH_RIGID, PH_SPHERE); // set the physics entity type
pXent_setfriction (ball,50); // set the friction on the ground
pXent_setdamping (ball,10,10); // set the damping
pXent_setelasticity (ball,50); // set the elasticity
pXent_setmass(my,1);
while(1)
{

//Pushs the ball if the character is 100 quants nearby
if(vec_dist(player.x,ball.x)<100){
VECTOR temp;
vec_set(temp,ball.x);
vec_sub(temp,player.x);
vec_normalize(temp,4);
pXent_addvelcentral(ball,vector(temp.x,temp.y,temp.z));
}
wait(1);
}
}


I added the #include <ackphysx.h>
and physX_open();

So please what is the problem here
Posted By: bk9iq

Help Please - 07/14/10 00:30

Any Help please....
Posted By: Superku

Re: Help Please - 07/14/10 00:32

Have patience...
Posted By: Liamissimo

Re: Help Please - 07/14/10 08:06

Ahhhh good. I also have this problem, take a look at my thread. I am so happy not to be the only one laugh
Posted By: bk9iq

Re: Help Please - 07/14/10 16:57

@ TheLiam
That's almost the same problem here and there...
I used to use a similar code with the old engine and it was working fine ... And the problem is that this code is given as an example in one of the physics functions in the manual..

So please somebody help us...
Posted By: Liamissimo

Re: Help Please - 07/14/10 17:14

Yes, exactly my problem. When suing the same code as in the manual is also don't work. Not good in a physic based game grin
Posted By: bk9iq

Re: Help Please - 07/14/10 17:15

Oh yeah me too.. I just don't get physics grin
Posted By: bk9iq

Re: Physics Problem - 07/15/10 21:30

If I move the player using pXent_movechar() everything works fine...
however When I use c_move and use the if statement:
if(vec_dist(player.x,ball.x)<100)
The ball doesn't move at all....

In A7 I used to use the same if statement and everything was just fine....
What should I do now?
Posted By: Widi

Re: Physics Problem - 07/15/10 21:37

Don`t move a physic object with c_move! Read the manual for this...
Posted By: bk9iq

Re: Physics Problem - 07/15/10 21:40

I am not moving a physics object with c_move .... I did not attach physics to my player therefore I am moving it with c_move ... I just attached physics to the ball.. but What I want is that...
when the player comes close to the ball , the ball moves by adding velocity (as simple as that) ...
Posted By: Widi

Re: Physics Problem - 07/15/10 21:42

OK, sorry, i misunderstand you blush Hope another can help here...
Posted By: bk9iq

Re: Physics Problem - 07/15/10 22:14

Oh that's OK ... thanks for answering me anyway ...
Posted By: MTD

Re: Physics Problem - 08/01/10 14:40

Tryed your code and everything works
(Created a Movable entity with c_move + assigned to this entity the player)

The only thing that could be is the physX_open(); must be called before level_load(levelName);

P.S. (I'm using 3D GameStudio A8 Trial version)
© 2024 lite-C Forums