|
Re: Enemy bend at waist
[Re: ]
#455631
10/26/15 04:46
10/26/15 04:46
|
Malice
Unregistered
|
Malice
Unregistered
|
action monster_code()
{
VECTOR vec_temp;
ANGLE vec_bend;
ANGLE ang_bpdiff;
var limit=0;
var limit2=0;
var limit3=0;
while(1)
{
// get the direction from the entity MY to the entity YOU
vec_to_angle(vec_bend.pan,vec_diff(NULL,player.x,my.x));
// now MY looks at YOU
ang_diff(ang_bpdiff,vec_bend.pan,my.pan);
if(abs(ang_bpdiff.pan) >90)
{
ent_bonereset(my,"bip01 Spine1");
vec_to_angle(my.pan,vec_diff(NULL,player.x,my.x));
ent_bonereset(my,"bip01 Spine1"); // may be overkill
my.tilt=0;
my.roll=0;
}
else
{
ent_bonereset(my,"bip01 Spine1");
limit=clamp(ang_bpdiff.tilt,-53,53); //min max
limit2=clamp(ang_bpdiff.pan,-90,90); //min max
limit3=clamp(ang_bpdiff.roll,-25,25); //min max
ent_bonerotate(my, "bip01 Spine1", vector(limit2,limit,limit3));
}
wait(1);
}
}
Code 100% tested and working with Tusker.mdl I got bored and felt like doing this. Think it's cool. BTW in the bottom left of MED - select the bone - you'll see two name blocks - the bone name bip01 Spine1 and the word"bone". the name is not bone. No need for a "thank you"- I thought playing with vec_to_ang and Ang_diff would be a fun reminder. Now I played with bones makes me want to build a bone animation system. Lol to much work... Have fun ,game dev on bill and ted Mal
Last edited by Malice; 10/26/15 05:11.
|
|
|
Re: Enemy bend at waist
[Re: Ruben]
#455642
10/26/15 16:31
10/26/15 16:31
|
Malice
Unregistered
|
Malice
Unregistered
|
Yeah ok, have fun. The code is run 100% crash free in my project so I can't fix that. Have fun.. Mal
action monster_code()
{
VECTOR vec_temp;
ANGLE vec_bend;
ANGLE ang_bpdiff;
var limit=0;
var limit2=0;
var limit3=0;
while(1)
{
// get the direction from the entity MY to the entity YOU
set(my,LIGHT);
vec_to_angle(vec_bend.pan,vec_diff(NULL,player.x,my.x));
// now MY looks at YOU
vec_sub(vec_bend.pan,my.pan);
if(abs(vec_bend.pan) >90)
{
my.red=255;
ent_bonereset(my,"bip01 Spine1");
vec_to_angle(my.pan,vec_diff(NULL,player.x,my.x));
ent_bonereset(my,"bip01 Spine1");
my.tilt=0;
my.roll=0;
}
else
{
my.red=0;
ent_bonereset(my,"bip01 Spine1");
limit=clamp(-vec_bend.tilt,-25,25); //min max
limit2=clamp(vec_bend.pan,-90,90); //min max
limit3=clamp(vec_bend.roll,-25,25); //min max
ent_bonerotate(my, "bip01 Spine1", vector(limit2,limit,0));
}
wait(1);
}
}
Last edited by Malice; 10/26/15 16:53.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|