Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (dr_panther, VoroneTZ, AndrewAMD, vicknick, 7th_zorro), 832 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
head tracking #260942
04/14/09 20:05
04/14/09 20:05
Joined: Jul 2005
Posts: 192
Orange County
S
silencer Offline OP
Member
silencer  Offline OP
Member
S

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:
Code:
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 Offline
Senior Expert
Pappenheimer  Offline
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
S
silencer Offline OP
Member
silencer  Offline OP
Member
S

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: silencer] #261118
04/15/09 22:05
04/15/09 22:05
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
I have never used bones in this way.

What about separating the task in two:

Can you rotate the head with keys?
Something like this:
temp1.pan += key_r;

Re: head tracking [Re: Pappenheimer] #261132
04/15/09 22:51
04/15/09 22:51
Joined: Jul 2005
Posts: 192
Orange County
S
silencer Offline OP
Member
silencer  Offline OP
Member
S

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:

Code:
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 Offline
Senior Expert
Pappenheimer  Offline
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 Offline
Serious User
gri  Offline
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: gri] #261276
04/16/09 16:18
04/16/09 16:18
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
gri, thanks for the insights, but I don't understand the second point.
Can't you play the walkcycle and ent_bone_rotate the head right after that?

In case that isn't possible, one could add a bone animation to the model with the head rotating and set its animation depending the position of the target at which the head shall look, right?

Re: head tracking [Re: Pappenheimer] #261291
04/16/09 18:15
04/16/09 18:15
Joined: Jul 2005
Posts: 192
Orange County
S
silencer Offline OP
Member
silencer  Offline OP
Member
S

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
Re: head tracking [Re: silencer] #261300
04/16/09 20:17
04/16/09 20:17
Joined: Aug 2003
Posts: 63
UK
ptrc1c Offline
Junior Member
ptrc1c  Offline
Junior Member

Joined: Aug 2003
Posts: 63
UK
Isn't this similar to workshop 23 in the online tutorial where part of the model tracks the movement of the mouse?.

Page 1 of 2 1 2

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