3 registered members (Ayumi, Akow, AndrewAMD),
1,505
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
head tracking
#260942
04/14/09 20:05
04/14/09 20:05
|
Joined: Jul 2005
Posts: 192 Orange County
silencer
OP
Member
|
OP
Member
Joined: Jul 2005
Posts: 192
Orange County
|
So I want to have an NPC to look at the player when the player passes within a certain vector distance, but I want them to track the player with a "neck" rotation, kind of like they do in Hitman. So far I have:
ent_animate(me,NULL,0,0); // reset all bones
ent_animate(me,"idle",skill_1,ANM_CYCLE);
vec_set(temp,player.x);
vec_sub(temp,silver_surfer.x);
vec_to_angle(silver_surfer.pan,temp);
temp1 = silver_surfer.pan + 90;
if ((vec_dist(silver_surfer.x, player.x)) < 200) {
ent_bonerotate(me,"joint13",vector(temp1,0,0) ); // rotate neck bone
}
I thought the above would work, but it seems to be rotating the entire entity. What gives?
Last edited by silencer; 04/14/09 20:15.
AMD 64 x2 4400+
2048mb DDR3200
NVidia 6800GS 256mb
Soundblaster Audigy 2
A7 Commercial 7.07
|
|
|
Re: head tracking
[Re: silencer]
#261097
04/15/09 19:53
04/15/09 19:53
|
Joined: Sep 2003
Posts: 5,900 Bielefeld, Germany
Pappenheimer
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
|
This is the part where you rotate the entire entity:
vec_to_angle(silver_surfer.pan,temp);
You can directly do this:
vec_to_angle(temp1,temp);
or like this, if needed:
vec_to_angle(temp1, vector(temp.pan + 90, temp.tilt, temp.roll));
|
|
|
Re: head tracking
[Re: Pappenheimer]
#261104
04/15/09 20:33
04/15/09 20:33
|
Joined: Jul 2005
Posts: 192 Orange County
silencer
OP
Member
|
OP
Member
Joined: Jul 2005
Posts: 192
Orange County
|
Hmm that still doesn't seem to update the "head" of the NPC. It just doesn't want to track the player position for some reason.
AMD 64 x2 4400+
2048mb DDR3200
NVidia 6800GS 256mb
Soundblaster Audigy 2
A7 Commercial 7.07
|
|
|
Re: head tracking
[Re: Pappenheimer]
#261132
04/15/09 22:51
04/15/09 22:51
|
Joined: Jul 2005
Posts: 192 Orange County
silencer
OP
Member
|
OP
Member
Joined: Jul 2005
Posts: 192
Orange County
|
Yes it's something that should be possible (I've done it in other game engines) but for the life of me I can't figure out how to do this in A7. Here's where I'm at right now:
while(1)
{
player_x = player.x;
silver_x = silver_surfer.x;
silver_pan = silver_surfer.pan;
ent_animate(me,NULL,0,0); // reset all bones
ent_bonereset(me,"joint13");
ent_animate(me,"idle",skill_1,ANM_CYCLE);
vec_set(temp,player_x);
vec_sub(temp,silver_x);
vec_to_angle(silver_pan,temp); // now Silver Surfer looks at Player
temp1 = silver_pan;
if ((vec_dist(silver_surfer.x, player.x)) < 200) {
ent_bonereset(me,"joint13");
ent_bonerotate(me,"joint13",vector(temp1,25,0) ); // rotate neck bone
}
I'm not sure if I need to reset the bone in the "if" statement. Also explain what you mean by splitting the task in two? When the player walks near an NPC, the NPCs head should track the player based on a vector distance, not a key action, if that makes any sense. I know I'm close, but the problem right now is that it seems the bone rotation is not being updated every frame, only once, and then that's it.
AMD 64 x2 4400+
2048mb DDR3200
NVidia 6800GS 256mb
Soundblaster Audigy 2
A7 Commercial 7.07
|
|
|
Re: head tracking
[Re: silencer]
#261178
04/16/09 08:10
04/16/09 08:10
|
Joined: Sep 2003
Posts: 5,900 Bielefeld, Germany
Pappenheimer
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
|
The splitting is meant for testing only. I would implement a key action to test whether the bone rotation updates at all.
I don't understand why you use the variables instead of the vectors.
This part isn't necessary:
player_x = player.x; silver_x = silver_surfer.x; silver_pan = silver_surfer.pan;
But, if you want to use the variables, you should declare them this way:
var player_x[3]; var silver_x[3]; var silver_pan[3];
They have to be vectors, that means, they need an array of 3, if you use them with the vector instructions vec_set, vec_add etc..
|
|
|
Re: head tracking
[Re: Pappenheimer]
#261235
04/16/09 13:57
04/16/09 13:57
|
Joined: Dec 2003
Posts: 1,225 germany
gri
Serious User
|
Serious User
Joined: Dec 2003
Posts: 1,225
germany
|
hi,
Dont use ent_bonerotate!
I did it and wasted much time.
problem #1 if you try any collsion-detection after the ent_bonerotate you will see that the bounding box doesnt moves to new position. (maybe not tragic on head, but on moving legs,arms...)
problem #2 if the model moves with ent_animate and should turn the head with ent_bonerotate to you it will fail because on each "walkcycle" the headposition get reset.
Both problems I described here in the forums a few weeks/days ago.
If you want I can search the links.
I was realy happy as I saw the "ent_bone..." commands got realize in the engine and did easiely animated a model with it. I had full control at runtime via script to each little finger - it was very cool. But without updated collision boundings it got useless for my needs and I throw it away. JCL stated in "Future forum" it would slow down the engine if ent_bonerotate would update boundingbox too.
greetings, gri
"Make a great game or kill it early" (Bruce Shelley, Ensemble Studios)
|
|
|
Re: head tracking
[Re: Pappenheimer]
#261291
04/16/09 18:15
04/16/09 18:15
|
Joined: Jul 2005
Posts: 192 Orange County
silencer
OP
Member
|
OP
Member
Joined: Jul 2005
Posts: 192
Orange County
|
On point#2, that's ridiculous that we can't manipulate a bone while using ent_animate. This is a very basic animation feature in most game engines.
Can one of the developers comment on this?
Last edited by silencer; 04/16/09 18:15.
AMD 64 x2 4400+
2048mb DDR3200
NVidia 6800GS 256mb
Soundblaster Audigy 2
A7 Commercial 7.07
|
|
|
|