Entity placed lower with gravity...

Posted By: Orange Brat

Entity placed lower with gravity... - 09/21/03 00:42

Started doodling with physics, I have a map entity, the motion is fine, but it is placed lower in the level than it is set in WED. I want it hanging from the ceiling, not 10 feet below it. Changing the earthgravity seems to affect the location...the smaller the Z the lower it gets...if I make it 0 it is ALMOST where it should be. So how do I keep it where it should be without compromising my motion?

Code:
var earthgravity[3] = 0,0,-386;
var hingeID;
var anchor[3];
var axis[3] = 1,0,0;
var allowed_angles[3] = -90,90,0;

action light_sway //level 1 hanging light
{
while(player == null) {wait(1);}
phent_settype( me, PH_RIGID, 0 );
phent_setmass ( me, 2.5, 0 );
phent_setdamping ( me, 30, 30 );
ph_setgravity( earthgravity );
waitt( 16 );
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);
}


Posted By: ventilator

Re: Entity placed lower with gravity... - 09/21/03 00:55

you shouldn't wait before applying the hinge!
Posted By: Orange Brat

Re: Entity placed lower with gravity... - 09/21/03 01:12

Not using a waitt or moving it results in no movement and it's still lower than where I set it only not as low.
Posted By: ventilator

Re: Entity placed lower with gravity... - 09/21/03 01:27

the hull type shouldn't be 0!
Posted By: Orange Brat

Re: Entity placed lower with gravity... - 09/21/03 01:35

The entity will never collide with anything, changing this has no affect. It should swing back and forth and does so nicely but only with a waitt..which leads to it getting lowered. Getting rid of the waitt does return it to where it should be(I was wrong in my last post), but there's no motion.
Posted By: ventilator

Re: Entity placed lower with gravity... - 09/21/03 01:53

i think without hull physics entities don't work properly.

gravity is a global setting. try to set it before this action starts!
Posted By: Orange Brat

Re: Entity placed lower with gravity... - 09/21/03 02:31

I stuck the gravity and phcons in the main and the pivot was in the center of the entity instead of the origin. It stays in place, but the entity is rotated for whatever reason when it stops moving.

This is starting to drive me bonkers. The only way to get it right is to use a waitt(16) but that allows it to sink..take it away and nothing....do what I just described and it is screwier.
Posted By: ventilator

Re: Entity placed lower with gravity... - 09/21/03 03:26

...it's strange that it doesn't work then! have you tried using a normal entity instead of a map entity?
Posted By: Orange Brat

Re: Entity placed lower with gravity... - 09/21/03 04:47

Yeah, no different..aww forget it, not worth the headaches..thanks for the pointers.
Posted By: Orange Brat

Re: Entity placed lower with gravity... - 09/21/03 09:58

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.
Posted By: seb_dup1

Re: Entity placed lower with gravity... - 09/21/03 17:28

Maybe , try phcon_setmotor .
Posted By: ventilator

Re: Entity placed lower with gravity... - 09/21/03 17:37

are you sure the level geometry doesn't prevent the entity from swinging? there shouldn't be any intersection going on! and you could try a ball constraint instead of a hinge constraint...
Posted By: Orange Brat

Re: Entity placed lower with gravity... - 09/21/03 18:25

It was a frickin' nullvector in addforcelocal...I've been putting in a vector for the vecPoint instead of just nulling it like I knew I was supposed to do...that's it problem solved...what a bunch of crap!
© 2024 lite-C Forums