Posted By: James_Burke
hinge physics- making it stay - 10/09/04 15:32
Hi,
I'm don't know anything much about physics. So you'll have to excuse my noobiness when it comes to physics
I've been adapting the code from 3PM Feb, and here's what I have:
Code:
Now, the problem is the door keeps going away from the hinge, which it shouldn't do. Have I missed something?
Here's a pic of it set up in WED incase there's a problem with that:
And here's the result:
Thanks for any help,
James
I'm don't know anything much about physics. So you'll have to excuse my noobiness when it comes to physics
I've been adapting the code from 3PM Feb, and here's what I have:
Code:
//-----------------------------
//Variable Defines
//-----------------------------
//Temp physic variables
var h_id;
var p2[3];
var p3[3];
var p4[3];
var p5[3];
var p6[3];
var door_max[3];
//-----------------------------
//Pointer Defines
//-----------------------------
entity* hinge; //Hinge pointer
//-----------------------------
//Actions
//-----------------------------
//---------------
//Desc: Hindge which connects the door
//---------------
action hinge_ent
{
hinge = my; //Give it the hinge pointer
my.passable = on; //Passable
wait(1);
}
//---------------
//Desc: A standard door
//---------------
action door
{
while(player == null)
{
wait(1); //Prevents empty pointers
}
phent_settype(my, ph_rigid, ph_box); //Is a physics object
phent_setgroup(my, 2);
phent_setmass(my, 100, ph_box);
phent_setfriction(my, 10);
phent_setelasticity(my, 2, 1);
//Sets the parameter vectors
vec_set(p2, vector(0, 0, 1));
vec_set(p3, vector(0, 0, 0));
vec_set(p4, vector(-90, 90, 0));
vec_set(p6, vector(0, 0, 0));
h_id = phcon_add(ph_hinge, my, hinge); ///Enables a 'hinge' joint
//Set the parameters
phcon_setparams1(h_id, hinge.x, p2, nullvector);
phcon_setparams2(h_id, p4, nullvector, nullvector);
//Set the speed
vec_set(door_max, vector(20, 10, 0));
phcon_setmotor(h_id, door_max, nullvector, nullvector);
}
Now, the problem is the door keeps going away from the hinge, which it shouldn't do. Have I missed something?
Here's a pic of it set up in WED incase there's a problem with that:
And here's the result:
Thanks for any help,
James