I like my headaches migraine style, so I'm taking one last jab at this so I'm going to restate my initial post with a better description of what I'm shooting for. Here's what I'm trying to accomplish(this is open to anyone..I'm sure ventilator wants to punch me
)...
I have a light hanging from the ceiling(map entity, not a model), it needs to be affected by a force that makes it swing back and forth like a pendulum, so it needs to be a HINGE style constraint. It should be connected to the level and not a 2nd entity, so I make the appropriate phcon_add parameter a "0" as called for in the manual. This light will probably never come in contact with any other entity, so I'm not concerned about it doing so(though I had always thought about making it shootable but I'll save that for another time).
The trick is is that I don't want it to be mechanical(if I wanted that, I wouldn't need physics)...I want it to be a random movement or at least appear that way, and the way the physics engine makes it move is perfect...it's organic and realistic.
The problem, as is apparent, is that this pendulum light will not move. I THINK it is set up correctly, but I cannot get it to move in place. I've tried applying some of the addforce instructions, but have had zero success.
Here's the code again, from above, with slight modifications:
Code:
var earthgravity[3] = 0,0,-386;
var hingeID;
var anchor[3];
var axis[3] = 1,0,0;
var allowed_angles[3] = -45,45,0;
action light_sway //level 1 hanging light
{
while(player == null) {wait(1);}
phent_settype( me, PH_RIGID, PH_SPHERE );
phent_setmass ( me, 2.5, PH_SPHERE );
phent_setdamping ( me, 30, 30 );
vec_set( anchor, me.x ); //
anchor.z = me.z;
hingeID = phcon_add( PH_HINGE, me, 0 );
phcon_setparams1( hingeID, anchor, axis, nullvector );
phcon_setparams2( hingeID, allowed_angles, nullvector, nullvector);
}
I understand that gravity must be called outside of the action...I've done this as well as getting rid of the waitt instruction...I'm guessing the the pause allowed the physics entity to fall and then when it stopped it was simply moving the object as it should(the constraint seemed to be the pivot point, so that is what leads me to believe that I have it setup correctly). That removal basically solves my original problem and tricked me into thinking I was getting the motion I wanted since it was merely reacting to being dropped.
The back and forth motion is not dependent on player interaction...it just sways harmlessly in a faked wind. So, a) I'm hoping for someone to confirm that my code is correct or am I just approaching this the wrong way?, and b) Assuming I'm on the right track, how do I move the light as I described?
Any additional pointers or suggestions would be welcomed..I've run out of tricks and aspirin.