Sorry for the double post, but I encounter a new problem. It is about the same simulation.
But I had add a new entity to it. And I want to move it with the end (underside of the model that swings) "klepel"-model. It is going quite good now. But if the "klepel" is coming 90 degrees, the attached model is rotating away. The "klepel"-model swings to a maximum of 120 degrees.
This is the code untill now (the attached model is named "kruis"):
Code:
// level.wdl
string level_str = <level.WMB>;
var swing;
var video_mode = 7;
var video_depth = 32;
var earthGravity[3] = 0,0,-368;
var klepel1;
function main()
{
bg_color.red = 10;
bg_color.green = 10;
bg_color.blue = 10; // Achtergrondkleur lichtzwart
//laad het level
level_load(level_str);
}
entity* steun1;
entity* klepel01;
entity* kruis1;
action kruis {
kruis1 = my;
my.passable = on;
my.scale_x = 0.600;
my.scale_y = 0.600;
my.scale_z = 0.600;
while(my) {
vec_for_vertex(temp,klepel01,567);
my.x = temp.x;
my.y = temp.y;
my.z = temp.z;
my.tilt = klepel01.tilt;
//c_rotate(my,vector(0,0,0),USE_AXIS);
wait(1);
}
}
action klepel {
klepel01 = my;
my.passable = on;
vec_for_vertex(temp,my,567);
ent_create("gondelkruis.mdl",temp,kruis);
//my.x = temp.x-10;
my.scale_x = 0.600;
my.scale_y = 0.600;
my.scale_z = 0.600;
//Physics on
phent_settype(my,PH_RIGID,PH_BOX);
//Set a weight
phent_setmass(my,23,PH_BOX);
//Set a friction
phent_setfriction(my,100);
//Set a damping
phent_setdamping(my,45,10);
//Set a gravity
ph_setgravity(earthGravity);
klepel1 = phcon_add(PH_HINGE,my,steun1);
phcon_setparams1(klepel1,vector(0,190,190),vector(0,190,0),nullvector);
phcon_setparams2(klepel1,vector(-120,120,0),nullvector,nullvector);
while(my) {
vec_for_vertex(temp,steun1,588);
phcon_setmotor(klepel1,vector(10,50,0),nullvector,nullvector);
if(key_cur == 1)//right key is pressed
{
phent_addtorquelocal (my,vector(0,-45,0));
}
if(key_cul == 1)//left key is pressed
{
phent_addtorquelocal (my,vector(0,45,0));
}
wait(1);
}
}
action steun01 {
steun1 = my;
vec_for_vertex(temp,my,588);
ent_create("draaiarm.mdl",temp,klepel);
}
Thanks in advance for help.