I was trying out Slider Constraint
I made 2 map entities -
1. Hollow Cylinder (One end open)
2. Cylinder with a smaller radius
Something same as the image given in the manual (without the cube though)
I am unable to move them on Z axis
here is my code
// Attached to the cylinder of lower radius
action upper
{
Up_Piston=my;
my.shadow=on;
while(Dw_Piston==NULL){wait(1);}
phent_settype(my,PH_RIGID,PH_BOX);
sleep(1);
phent_setgroup(my,2);
phent_setmass(my,10,PH_BOX);
phent_setfriction(my,0);
phent_setelasticity(my,0,0);
phent_setdamping(my,0,0);
vec_set(p2,vector(0,0,1));
vec_set(p3,vector(-400,400,0));
UPPER_ID=phcon_add(PH_SLIDER,Dw_Piston,my);
phcon_setparams1(UPPER_ID,p2,nullvector,nullvector);
phcon_setparams2(UPPER_ID,p3,nullvector,nullvector);
}
// attached to hollow cylinder
action lower
{
Dw_Piston=my;
my.shadow=on;
while(Up_Piston==NULL){wait(1);}
phent_settype(my,PH_RIGID,PH_BOX);
sleep(1);
phent_setgroup(my,2);
phent_setmass(my,10,PH_BOX);
phent_setfriction(my,0);
phent_setelasticity(my,0,0);
phent_setdamping(my,0,0);
}
// forces
if(key_a==1)
{
vec_set(m1,vector(-50,250,0));
phcon_setmotor(UPPER_ID,m1,nullvector,nullvector);
}
if(key_s==1)
{
vec_set(m1,vector(50,250,0));
phcon_setmotor(UPPER_ID,m1,nullvector,nullvector);
}
If i keep the entire system verticle it doesnt work
if i rotate the entire system and change p2 to
vec_set(p2,vector(1,0,0));
Same code works.
Moreover if i use PH_CYLINDER instead of PH_BOX my cylinders just penitrate the floor and disappear (as if no collision)