hiho,
I'm trying to get through the physics in A7 and I already understand how it works. But nonetheless after programming some simple kickable balls I am completly stuck on a simple door.
After a lot of trial and error I got the following code:
Code:
function push_event{
if(event_type==event_impact){
vec_set(temp,my.x);
vec_sub(temp,you.x);
vec_scale(temp,50);
phent_addcentralforce(me,temp);
}
}
action gittertor{
var hingeId;
var hingeIdb;
my.passable=off;
vec_set(my.skill40,my.x);
vec_set(my.skill43,my.pan);
my.enable_impact=on;
my.event=push_event;
phent_settype(me,PH_RIGID,PH_BOX);
phent_setmass(me,30,PH_BOX);
phent_setelasticity(me,0,0);
phent_setdamping(me,10,10);
phent_setfriction(me,10);
hingeId=phcon_add(PH_HINGE,me,null);
phcon_setparams1(hingeID,vector(my.x,my.y,my.z+30),vector(0,0,1),nullvector);
phcon_setparams2(hingeID,vector(-45,45,0),nullvector,nullvector);
hingeIdb=phcon_add(PH_HINGE,me,null);
phcon_setparams1(hingeIDb,vector(my.x,my.y,my.z-30),vector(0,0,1),nullvector);
phcon_setparams2(hingeIDb,vector(-45,45,0),nullvector,nullvector);
//ph_setautodisable (0.01, 0.008, 10, 0.1);
}
But my door behaves like a pendulum. I tried to set the axis to (1,0,0) and to (0,1,0)...but there wasn't a change.