|
Camera.Target
#108810
01/24/07 04:20
01/24/07 04:20
|
Joined: Feb 2005
Posts: 324
laethyn
OP
Senior Member
|
OP
Senior Member
Joined: Feb 2005
Posts: 324
|
As I posted elsewhere (in the wrong thread):
I've not updated in some time, so I don't know for certain if this has been implemented or not, but some sort of "target" function would be fantastic.
Something like
view 1stPerson { .... target = player;
} or 1stPerson.target = player;
You get the idea.
This would be absolutely fantastic not only for views, but to point entities at other entities (ex. during combat, you set the player target to the monster, and the player constantly faces the target.
I realize this can be done via vec_to_angle et al. but having a .target handle the angles would be a lifesaver for a lot of people.
Read the manual, it's a good place to start learning ~ ulillillia
|
|
|
Re: Camera.Target
[Re: laethyn]
#108811
01/24/07 05:48
01/24/07 05:48
|
Joined: Sep 2002
Posts: 8,177 Netherlands
PHeMoX
Senior Expert
|
Senior Expert
Joined: Sep 2002
Posts: 8,177
Netherlands
|
I don't think it's more useful than the normal code we would use. I also wonder if it would be any faster, probably not since it will be checking the angles constantly. Besides, you only need a few lines: Code:
function turn_towards_target() { // get the direction from the entity MY to the entity YOU vec_set(temp,your.x); vec_sub(temp,my.x); vec_to_angle(my.pan,temp); // now MY looks at YOU }
Simplest approach would be to use pointers for your 'targets' like this: Code:
entity* target1; //different kind of enemies entity* target2; [..]
Then you can use: Code:
function turn_towards_target() { // get the direction from the entity player to the entity target1 vec_set(temp,player.x); vec_sub(temp,target1.x); vec_to_angle(target1.pan,temp); // enemy now looks at player }
Cheers
|
|
|
Re: Camera.Target
[Re: PHeMoX]
#108812
01/24/07 13:50
01/24/07 13:50
|
Joined: Jan 2003
Posts: 4,615 Cambridge
Joey
Expert
|
Expert
Joined: Jan 2003
Posts: 4,615
Cambridge
|
enhancing all that... Code:
define spot_track, skill51; define target, skill1;
function spot(ent) { if (ent == null) { my.spot_track = 0; my.target = null; return; }
my.target = handle(ent); my.spot_track ++;
while (my.spot_track == 1) { if (my.target != null) { you = ptr_for_handle(my.target); vec_set(temp.x, you.x); vec_sub(temp.x, my.x); vec_to_angle(my.pan, temp.x); } wait(1); } }
haven't tested that, though i think you get the idea of comfort you have with such little functions. so instead of requesting an "engine" feature, you should rather think over your problem once more. joey.
|
|
|
Re: Camera.Target
[Re: Joey]
#108813
01/24/07 16:15
01/24/07 16:15
|
Joined: Feb 2005
Posts: 324
laethyn
OP
Senior Member
|
OP
Senior Member
Joined: Feb 2005
Posts: 324
|
As said in my post, I'm aware it can be done, and I have no problems doing it, but let's count with me, shall we? Here's some example code useing a "target" function: Code:
1) action TheTarget 2) { 3) TargEnt = me; 4) }
5) action Player 6) { 7) player = me; 8) player.target = TargEnt; 9) }
That would be 9 lines of code. Now let's lay out your code in the same manner: Code:
1) define spot_track, skill51; 2) define target, skill1; 3) function spot(ent) 4) { 5) if (ent == null) 6) { 7) my.spot_track = 0; 8) my.target = null; 9) return; 10) } 11) my.target = handle(ent); 12) my.spot_track ++; 13) while (my.spot_track == 1) 14) { 15) if (my.target != null) 16) { 17) you = ptr_for_handle(my.target); 18) vec_set(temp.x, you.x); 19) vec_sub(temp.x, my.x); 20) vec_to_angle(my.pan, temp.x); 21) } 22) wait(1); 23) } 24)}
24 lines of code. Sure, there is a difference. But it's also about the EASE in which things are done for the end user. Making a panel in WED that then allows simple target selecting would be a fantastic boon for new users.
Read the manual, it's a good place to start learning ~ ulillillia
|
|
|
Re: Camera.Target
[Re: Doug]
#108816
01/25/07 01:11
01/25/07 01:11
|
Joined: Feb 2005
Posts: 324
laethyn
OP
Senior Member
|
OP
Senior Member
Joined: Feb 2005
Posts: 324
|
Like I said, I don't have a problem with it, just someone I was working with on something had been trying to figure out how to get something to "point" at another and this idea was brought up.
Cheers!
Read the manual, it's a good place to start learning ~ ulillillia
|
|
|
|