Ragdoll has no gravity

Posted By: Blackchuck

Ragdoll has no gravity - 11/17/09 19:12

The Ragdoll worked good till I added (mystymoon).
Now it still works but there is no more gravity, I used for the grafity;
"ph_setgravity(vector(0, 0, -1500));"

"http://dl8.rapidshare.de/files/48696949/682793447/shot_0.jpg"

(Post me for more information)
And wenn the grafity works, everybody can copy it in his own projeckt, the die function is called "die_soldier()"

And I will post here the ragdollscript, when it`s ok?;
_______________________________________________________________

#define PRAGMA_PATH "scripts"
#define PRAGMA_PATH "models"
#define PRAGMA_PATH "textures"//for level (mystymood)

#include <acknex.h>
#include <default.c>
#include "level.c"// (mystymood)

#define PRAGMA_PATH "body_dummy";

STRING* level_str = "level.wmb";

VECTOR Hinge1, Hinge2;

var GroupID = 2;
var low_rot_dist = 5;

function die_soldier();

void updateBoneHinge(ENTITY* hingeEnt, STRING* bodyPart, ENTITY* actor) {
VECTOR temp_pos, temp_ang, temp_mov, temp_ang_1;

ENTITY* hingePointer = hingeEnt;
ENTITY* actorPointer = actor;
STRING* updatePart = bodyPart;

while(hingePointer) {

ent_bonereset(actorPointer, updatePart);

vec_for_bone(temp_pos, actorPointer, updatePart);
ang_for_bone(temp_ang, actorPointer, updatePart);

vec_set(temp_mov, hingePointer.x);
vec_sub(temp_mov, temp_pos);

temp_mov.x = actorPointer.scale_x; temp_mov.y = actorPointer.scale_y; temp_mov.z = actorPointer.scale_z;
temp_ang.x = 360-temp_ang.x; temp_ang.y = 360-temp_ang.y; temp_ang.z = 360-temp_ang.z;

vec_set(temp_ang_1, nullvector);
ang_add(temp_ang_1, vector(temp_ang.x,0,0));
ang_add(temp_ang_1, vector(0,temp_ang.y,0));
ang_add(temp_ang_1, vector(0,0,temp_ang.z));

ang_rotate(temp_ang_1, hingePointer.pan);
ent_bonerotate(you, updatePart, temp_ang_1);

wait(1);
}
}

void setLimit(VECTOR* vec1, VECTOR* vec2) {
vec_set(Hinge1, vec1);
vec_set(Hinge2, vec2);
}

void BodyPartInit(var mass, ENTITY* entityMe) {
set(entityMe, PASSABLE);

entityMe.pan = 180;

phent_settype(entityMe, PH_RIGID, PH_BOX);
phent_setmass(entityMe, mass, PH_BOX);

phent_setgroup(entityMe, GroupID);
phent_setfriction(entityMe, 40);
phent_setdamping(entityMe, 40, 40);
phent_setelasticity(entityMe, 10, 10);

reset(entityMe, PASSABLE);
}

void setHinge(ENTITY* constr_1, ENTITY* constr_2) {
var tempHinge;

tempHinge = phcon_add(PH_HINGE, constr_1, constr_2);
phcon_setparams1(tempHinge, constr_1.x, Hinge1, nullvector);
phcon_setparams2(tempHinge, Hinge2, nullvector, nullvector);
}

void setRagdollPart() {
set(my, INVISIBLE);
}

function die_soldier() {
ENTITY* Ent_1;
ENTITY* Ent_2;
ENTITY* Ent_3;

GroupID += 1;

var tempVertex;

you = ent_create("dummy.mdl.", nullvector, NULL);
set(you, PASSABLE);

Ent_1 = my;
setRagdollPart();
BodyPartInit(20, Ent_1);
setHinge(Ent_1, Ent_1);

vec_for_vertex(tempVertex, Ent_1, 23);
Ent_2 = ent_create("leg_up_left.mdl", tempVertex, setRagdollPart);
setLimit(vector(1,1,1), vector(-40,40,0));
BodyPartInit(5, Ent_2);
setHinge(Ent_2, Ent_1);
updateBoneHinge(Ent_2, "leg_up_left", you);

vec_for_vertex(tempVertex, Ent_2, 9);
Ent_3 = ent_create("leg_down_left.mdl", tempVertex, setRagdollPart);
setLimit(vector(0,1,0), vector(0,120,0));
BodyPartInit(20, Ent_3);
setHinge(Ent_3, Ent_2);
updateBoneHinge(Ent_3, "leg_down_left", you);

vec_for_vertex(tempVertex, Ent_1, 22);
Ent_2 = ent_create("leg_up_right.mdl", tempVertex, setRagdollPart);
setLimit(vector(1,1,1), vector(-40,40,0));
BodyPartInit(5, Ent_2);
setHinge(Ent_2, Ent_1);
updateBoneHinge(Ent_2, "leg_up_right", you);

vec_for_vertex(tempVertex, Ent_2, 9);
Ent_3 = ent_create("leg_down_right.mdl", tempVertex, setRagdollPart);
setLimit(vector(0,1,0), vector(0,120,0));
BodyPartInit(20, Ent_3);
setHinge(Ent_3, Ent_2);
updateBoneHinge(Ent_3, "leg_down_right", you);

vec_for_vertex(tempVertex, Ent_1, 21);
Ent_2 = ent_create("abs.mdl", tempVertex, setRagdollPart);
setLimit(vector(1,1,0), vector(-15,15,0));
BodyPartInit(20, Ent_2);
setHinge(Ent_2, Ent_1);
updateBoneHinge(Ent_2, "stomach", you);

vec_for_vertex(tempVertex, Ent_2, 17);
Ent_1 = ent_create("torso.mdl", tempVertex, setRagdollPart);
setLimit(vector(1,1,0), vector(-20,20,0));
BodyPartInit(55, Ent_1);
setHinge(Ent_1, Ent_2);
updateBoneHinge(Ent_1, "torso", you);

vec_for_vertex(tempVertex, Ent_1, 21);
Ent_2 = ent_create("arm_up_left.mdl", tempVertex, setRagdollPart);
setLimit(vector(1,1,1), vector(-70, 116,20));
BodyPartInit(5, Ent_2);
setHinge(Ent_2, Ent_1);
updateBoneHinge(Ent_2, "arm_up_left", you);

vec_for_vertex(tempVertex, Ent_2, 9);
Ent_3 = ent_create("arm_down_left.mdl", tempVertex, setRagdollPart);
setLimit(vector(1,1,0), vector(270,0,0));
BodyPartInit(20, Ent_3);
setHinge(Ent_3, Ent_2);
updateBoneHinge(Ent_3, "arm_down_left", you);

vec_for_vertex(tempVertex, Ent_1, 22);
Ent_2 = ent_create("arm_up_right.mdl", tempVertex, setRagdollPart);
setLimit(vector(1,1,1), vector(-70,116,20));
BodyPartInit(5, Ent_2);
setHinge(Ent_2, Ent_1);
updateBoneHinge(Ent_2, "arm_up_right", you);

vec_for_vertex(tempVertex, Ent_2, 9);
Ent_3 = ent_create("arm_down_right.mdl", tempVertex, setRagdollPart);
setLimit(vector(1,1,0), vector(270,0,0));
BodyPartInit(20, Ent_3);
setHinge(Ent_3, Ent_2);
updateBoneHinge(Ent_3, "arm_down_right", you);

vec_for_vertex(tempVertex, Ent_1, 23);
Ent_2 = ent_create("head.mdl", tempVertex, setRagdollPart);
setLimit(vector(1,1,0), vector(-45,45,0));
BodyPartInit(25, Ent_2);
setHinge(Ent_2, Ent_1);
updateBoneHinge(Ent_2, "head", you);

while(you) {
vec_set(you.x, my.x);
vec_set(you.pan, my.pan);

wait(1);
}
}

void main() {
vec_set(Hinge1, nullvector);
vec_set(Hinge2, nullvector);

video_screen = 1;
video_mode = 8;
fps_max = 100;
ph_iterations = 20;
time_smooth = 0.99;
clip_size = 0;
var max_entities = 5000;
terrain_chunk = 64;

wait(1);
level_load("test_level.wmb");
wait(3);
wait(-1);

ph_setgravity(vector(0, 0, -1500));
ph_setcorrections(9000, 0);
ph_setcollisions(1000, 2);
wait(1);
}

ENTITY* actor;

action ragdoll()
{
actor = me;
wait (1);
my.event = die_soldier();
}
Posted By: Helghast

Re: Ragdoll has no gravity - 11/24/09 16:31

you need a hollow block around the level... also, this aint your code, it's mine, dont claim it's yours.
Posted By: Blackchuck

Re: Ragdoll has no gravity - 11/24/09 18:30

I didn`t saw that this code is from me, I sayèd "that code" not my code.

And is it realey from you? I got it out of the aum then I writen it alittlebit to an function (I think it was aum 83).

And why du I need a hollow block around the level to let the gravity work?

still thanks
Posted By: Helghast

Re: Ragdoll has no gravity - 11/25/09 08:28

Yes, it's really mine, but dont worry wink

Anyway, it's a common made user-error that people dont have a huge hollow block around their level. I quote from the manual:

Quote:
Q: I don't get any gravity even though I set it via ph_setgravity at the beginning of the main function ?
A: Global physics parameters get reset when a new level is loaded. Thus you should first call level_load, wait 1 frame and then call ph_setgravity to set properties of the new level.


and also:

Quote:
Q: I've made a small level with only a few objects, and placed a ball into it. When I kick the ball into the air, it seems to hit an invisible barrier at some position.
A: Check the sky box around your level. The ball possibly collides with a side or the top of the sky box. If there is no sky box around your level at all, the level size is automatically limited to an area that contains all the objects. In this case, create a sky box in WED - a hollow cube with sky texture - and make it large enough for the ball to reach the desired height.


Hope that helps, good luck laugh
regards,
Posted By: Blackchuck

Re: Ragdoll has no gravity - 11/27/09 13:44

I works!
Thanks, thats very nice, just wright me if I can avenge wink
Posted By: Blackchuck

Re: Ragdoll has no gravity - 11/30/09 16:34

I have just one more questin.
So action ragdoll worked;
________________________________________________________________________________
ENTITY* actor;

action ragdoll()
{
actor = me;
wait (1);
my.event = die_soldier();
}
________________________________________________________________________________

But why does this don`t work?;

________________________________________________________________________________

function collision();
VECTOR speed;

action free_camera()
{
player = my;
my.skill1 = 1;
my.emask |= (ENABLE_IMPACT | ENABLE_ENTITY | ENABLE_BLOCK);
c_setminmax(me);
my.event = collision;
while (my.skill1 == 1)
{
c_move (my, vector(10 * (key_w - key_s) * time_step, 6 * (key_a - key_d) * time_step, 0), nullvector, GLIDE);
camera.genius = me;
camera.pan -= 15 * mouse_force.x * time_step;
camera.tilt += 15 * mouse_force.y * time_step;
camera.x = player.x - 200;
camera.y = player.y;
camera.z = player.z + 20;
wait (1);
}
}

function collision()
{
wait(1);
my.skill1 = 0;
my.event = die_soldier();
}
________________________________________________________________________________

Whats wronge here?
thanks
greads
Posted By: Helghast

Re: Ragdoll has no gravity - 12/01/09 12:15

I cant really see what you're trying to do?
can you explain that first laugh I'll try to help you through this then.

regards,
Posted By: Blackchuck

Re: Ragdoll has no gravity - 12/01/09 18:50

I just want that my action free_camera turns into an ragdoll wenn it touthes somthing.
Then when it works here I can use it everyware wink
Posted By: Helghast

Re: Ragdoll has no gravity - 12/01/09 22:35

you're setting an even to another event, that wont work in this case tongue
change the my.event = collision; in free_camera function to my.event = die_soldier;

(also dont add () behind that die_soldier function, it will not work properly otherwise).

regards,
Posted By: Blackchuck

Re: Ragdoll has no gravity - 12/03/09 17:39

Oh... (up`s)
Thank, again wink
Posted By: Blackchuck

Re: Ragdoll has no gravity - 12/04/09 17:05

hmm...
Do you think it is passable to make ragdolls only with bones?
Posted By: xXxGuitar511

Re: Ragdoll has no gravity - 12/06/09 23:11

....this is the same thing really. You can combine 3DGS functions to find the length of a bone, and then scale the model to fit before adding it to the physics system. Then you can create all your skeletons automatically.

The trick is to only create your skeleton of physics one you need them. Just animate the model as normal, then once you need them, call your function to create the skeleton, rotate it to match the current bones angles, then cancel your models animation function, and have it switch to a "matching the hinge angles" function. Then when your done with them, destroy the physics models, and have the bones do a blend into a "getting up" animation.
Posted By: Blackchuck

Re: Ragdoll has no gravity - 12/16/09 16:02

Yes, I tryed it, it works.
Were can I upload fotos?
© 2024 lite-C Forums