Gamestudio Links
Zorro Links
Newest Posts
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
Deeplearning Script
by wolfi. 02/26/24 12:46
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/22/24 16:22
AssetAdd() vs. modern asset list?
by jcl. 02/21/24 15:01
How many still using A8
by Aku_Aku. 02/20/24 12:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (TipmyPip, 1 invisible), 526 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Pan/Tilt in relation to entity? #472754
05/20/18 23:27
05/20/18 23:27
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
I know that if I want to determine how much distance there is between the player and an entity, I can use the vec_dist() function, like this:

Code:
distanceDifference = vec_dist (player.x, otherEntity.x);

if(distanceDifference < 70)
{
   beep();
}



So in this case, if the distance in units between the player and the other entity is less than 70 units, the game starts beeping.

It is nice to know there is a function that lets us know the distance between two entities.

Is there a similar function allowing us to know how much the player is panned and/or tilted away from the other entity, to where if the player was pointed directly at the other entity, the number indicator would equal 0. If the player panned right or left away from that same entity, the pan number indicator would increase or decrease from 0. The same for if the player tilted up or down away from that same entity, the tilt number indicator would increase or decrease from 0?

So instead of measuring distance from the player to the entity, it would measure how much the player is panned or tilted away from the entity instead?

I think I might be able to use the vec_to_angle() function to do this, but I am trying to figure out how this would be done. Any help would be greatly appreciated. Thank you.

Last edited by Ruben; 05/20/18 23:54.
Re: Pan/Tilt in relation to entity? [Re: Ruben] #472758
05/21/18 08:17
05/21/18 08:17
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain

Re: Pan/Tilt in relation to entity? [Re: txesmi] #472764
05/21/18 09:30
05/21/18 09:30
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Alternatively, you could use the dot product which should be faster and maybe even more intuitive to use in this case. Something like this:

Code:
VECTOR dir1,dir2;

vec_for_angle(dir1,player.pan);
vec_diff(dir2,otherEntity.x,player.x);
vec_normalize(dir1,1);
vec_normalize(dir2,1);

vec_dot(dir1,dir2) -> 1 if player is facing otherEntity,
                     -1 if player is facing in the exact opposite direction



"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Pan/Tilt in relation to entity? [Re: Superku] #472792
05/23/18 15:12
05/23/18 15:12
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Thank you Superku! Your idea seems to be working. Thank you again! And thank you txesmi as well. :-)

Re: Pan/Tilt in relation to entity? [Re: Ruben] #472796
05/23/18 18:59
05/23/18 18:59
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
You're welcome! Just something I've noticed looking at my post:

vec_for_angle(dir1,player.pan);

dir1 is already normalized (meaning to length 1), so you can drop the vec_normalize(dir1,1) instruction.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Pan/Tilt in relation to entity? [Re: Superku] #472816
05/25/18 01:39
05/25/18 01:39
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Thank you Superku. :-)


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