Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, The_Judge, Grant), 898 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
bones: turn head.pan to player #146407
08/07/07 15:57
08/07/07 15:57
Joined: Nov 2003
Posts: 433
The Netherlands
T
Toon Offline OP
Senior Member
Toon  Offline OP
Senior Member
T

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: Toon] #146408
08/07/07 16:55
08/07/07 16:55
Joined: Sep 2002
Posts: 700
Orange County, CA
L
LogantheHogan Offline
Developer
LogantheHogan  Offline
Developer
L

Joined: Sep 2002
Posts: 700
Orange County, CA
before the ent_bonerotate, try

var tempvar[3];
vec_to_angle(tempvar,temp);

and then

ent_bonerotate(me,"head",vector(tempvar.pan,0,0));

Re: bones: turn head.pan to player [Re: LogantheHogan] #146409
08/07/07 17:04
08/07/07 17:04
Joined: Nov 2003
Posts: 433
The Netherlands
T
Toon Offline OP
Senior Member
Toon  Offline OP
Senior Member
T

Joined: Nov 2003
Posts: 433
The Netherlands
it still spins

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
O
Orange Brat Offline

Senior Expert
Orange Brat  Offline

Senior Expert
O

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: Toon] #146411
08/07/07 17:07
08/07/07 17:07
Joined: Sep 2002
Posts: 700
Orange County, CA
L
LogantheHogan Offline
Developer
LogantheHogan  Offline
Developer
L

Joined: Sep 2002
Posts: 700
Orange County, CA

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 Offline
Expert
Helghast  Offline
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,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1