Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,014 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Camera.Target #108810
01/24/07 04:20
01/24/07 04:20
Joined: Feb 2005
Posts: 324
laethyn Offline OP
Senior Member
laethyn  Offline 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 Offline
Senior Expert
PHeMoX  Offline
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


PHeMoX, Innervision Software (c) 1995-2008

For more info visit: Innervision Software
Re: Camera.Target [Re: PHeMoX] #108812
01/24/07 13:50
01/24/07 13:50
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
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 Offline OP
Senior Member
laethyn  Offline 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: laethyn] #108814
01/24/07 16:53
01/24/07 16:53
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
well, that is indeed correct.

Re: Camera.Target [Re: Joey] #108815
01/25/07 00:36
01/25/07 00:36
Joined: Jul 2000
Posts: 8,973
Bay Area
Doug Offline
Senior Expert
Doug  Offline
Senior Expert

Joined: Jul 2000
Posts: 8,973
Bay Area
Other than saving a few lines of code, there isn't any reason for this. It would either do too little to be very useful, or so much that it would slow things down.

Write a c-script function: function turn_to_ent(ENTITY* ent) and call it as needed. 8 lines of code for the function, 1 line of code to call it (3-4 if you want it to update it each frame).


Conitec's Free Resources:
User Magazine || Docs and Tutorials || WIKI
Re: Camera.Target [Re: Doug] #108816
01/25/07 01:11
01/25/07 01:11
Joined: Feb 2005
Posts: 324
laethyn Offline OP
Senior Member
laethyn  Offline 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

Moderated by  aztec, Spirit 

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