Well, guys, I'm having a bit of a problem here. I have this ball model on my map, which I'm using as an anchor for the camera object. I wanted the camera to move in a smooth and realistic manner, so I have set the ball as a physics entity, and put a while(1) inside the entity action that moves the camera to a constant position relative to the ball.
but I'm getting this nasty error where when I enable the physics engine for the ball, a force is applied to it in a up-right direction. I didn't put ANY force in the ball, yet it moves by itself. I really don't understand, it's like some ghosts pushed the ball...
look at the ball's action, maybe you guys can figure out this mystery...
Code:
action handle_sphere() {
my.scale_x = 0.2;
my.scale_y = 0.2;
my.scale_z = 0.2;
var earthgravity[3] = 0,0, -386;
phent_settype(my, PH_RIGID, PH_SPHERE);
phent_setfriction(my,100);
phent_setmass (my, 25, PH_SPHERE);
//phent_setdamping(my,50,0);
phent_setgroup(my,1);
phent_setelasticity (my, 100, 100);
phent_enable(my, 1);
//ph_setgravity(earthgravity);
my.transparent = on;
my.alpha = 65;
focus_x = my.x;
focus_y = my.y;
focus_z = my.z;
var s_temp[3];
while (1) {
vec_set(s_temp,vector(120,-120,110));
vec_add(s_temp,my.x);
vec_set(camera.x,s_temp);
vec_set(s_temp,my.x);
vec_sub(s_temp,camera.x);
vec_to_angle (camera.pan,s_temp);
wait(1);
}
}
By the way, the damping and gravity setting instructions are commented because I wanted to figure out the actual force being applied to the ball. Commenting those lines, the ball flies up and to the right forever. Without commenting those lines the ball rolls to the right de-accelerating until it stops. it's really strange, because I DIDN'T APPLY any force to the ball. thanks in advance
EDIT: I got some more info by putting some strategic watches and phent_getvelocity instructions:
1-) the mysterious force is applied to the ball 2 frame cycles after the phent_settype instruction
2-) the force applied to the ball is given by the vector (149.63,0,55.12)
3-) it appears that some torque is applied to the ball also. If the ball hits the map's skybox, it bounces off rolling a bit, and I also got differences in the velocity when I set phent_setmaxspeed to (1000,0.00001). I got these velocities from point 0,0,0.