|
|
bones: turn head.pan to player
#146407
08/07/07 15:57
08/07/07 15:57
|
Joined: Nov 2003
Posts: 433 The Netherlands
Toon
OP
Senior Member
|
OP
Senior Member
Joined: Nov 2003
Posts: 433
The Netherlands
|
hello, i want to create a supporter for a race game that turns his head (pan) to the player all the time i created a mdl and named the head-bone "head" Code:
action car_sprtr { ent_animate(my,"stand",my.skill2,ANM_ADD + ANM_CYCLE);
while(!player){wait(1);} while(1) { vec_set(temp,player.x); vec_sub(temp,my.x); ent_bonerotate(me,"head",vector(temp.pan,0,0)); wait(1); } }
instead of turning his head to the player it keeps spinning verry fast around his axis.
|
|
|
Re: bones: turn head.pan to player
[Re: LogantheHogan]
#146410
08/07/07 17:07
08/07/07 17:07
|
Joined: Aug 2000
Posts: 7,490
Orange Brat

Senior Expert
|

Senior Expert
Joined: Aug 2000
Posts: 7,490
|
Here's the beginning of my animation function. This code makes my player's head turn (via it's head bone) to look at certain flagged objects (the current objPtr (object pointer)...I have a lot of potential "look at" objects). It constrains the pan and tilt of the head based on the values in the my.skill15/skill15 lines: Code:
while(!player) { wait(1); } while(!objPtr) { wait(1); } you = objPtr; ent_animate(me,null,0,0); //Reset Bones vec_set(my.skill63,you.x);//Stores the position to look at vec_sub(my.skill63,my.x); //Not its relative vec_to_angle(temp,my.skill63); //Temp stores the angles needed vec_sub(temp,me.pan); temp.pan = ang(temp.pan); temp.tilt=ang(temp.tilt); //This works fine for me... //me.skill15 -= (me.skill15-clamp(temp.pan,-70,70)*(abs(temp.pan)<105)*(abs(temp.pan)>30))*0.3*time_step; //me.skill16 -= (me.skill16-clamp(temp.tilt,-25,25)*(abs(temp.tilt)<55)*(abs(temp.tilt)>35))*0.3*time_step; my.skill15 -= (my.skill15-clamp(temp.pan,-70,70))*time_step; my.skill16 -= (my.skill16-clamp(temp.tilt,-25,25))*time_step; ent_bonerotate(me,"Bip01_Head",vector(me.skill15,me.skill16,0));
My User Contributions master list - my initial post links are down but scroll down page to find list to active links
|
|
|
Re: bones: turn head.pan to player
[Re: LogantheHogan]
#146412
08/07/07 19:26
08/07/07 19:26
|
Joined: Jan 2004
Posts: 3,023 The Netherlands
Helghast
Expert
|
Expert
Joined: Jan 2004
Posts: 3,023
The Netherlands
|
here's what i have in my code: Code:
my.skill2=200; // if the player is in this range, the npc turns its head
vec_diff(temp.x, player.x, my.x); vec_to_angle(temp.pan, temp.x); my.skill43=ang(temp.pan);
if(vec_dist(player.x, my.x)<my.skill2 && abs(ang(my.pan-my.skill43))<70) { my.skill41=clamp(my.skill41+0.3*time, 0,1); } else { my.skill41=clamp(my.skill41-0.3*time, 0,1); } if(my.skill41>0.0001) { my.skill43=ang(my.skill43-my.pan); ent_bonerotate(my,"Bone14",vector(my.skill43*my.skill41*0.8,0,0)); // 0.8+0.2 = 1.0 ent_bonerotate(my,"Bone1",vector(my.skill43*my.skill41*0.2,0,0)); } The head itself is attached to bone 14, and the neck is attached to bone 1, you can add more bones for the rotation, but make sure the added number allways makes a total amount of 1. the added number is the % it rotates towards the correct point  this should work great! regards,
|
|
|
|