Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,709 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
vec_to_angle and tilt #146938
08/09/07 17:18
08/09/07 17:18
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline OP
User
demiGod  Offline OP
User

Joined: Mar 2006
Posts: 752
Portugal
Heya,

this question... well

Its simple:

I want an entity to turn towards a target

Code:

vec_set(temp,vecTarget.x);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp);



In order to maintain the entity vertical i will use my.tilt = 0.

But i want to control the entity´s TILT like rotating and pointing always to the target, vg. my.tilt += 10 * time_step;

But this dont work, so i ask which will be the way to do that?

Thanks.
Cheers

Re: vec_to_angle and tilt [Re: demiGod] #146939
08/09/07 17:39
08/09/07 17:39
Joined: Jun 2005
Posts: 656
G
Grafton Offline
User
Grafton  Offline
User
G

Joined: Jun 2005
Posts: 656
Can you explain a little more on specifically what you want?
Do you mean like a gun turret tracking an aircraft?
Perhaps you need to set roll to 0, and let pan and tilt be
set by vec_to_angle.


Not two, not one.
Re: vec_to_angle and tilt [Re: Grafton] #146940
08/09/07 17:46
08/09/07 17:46
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline OP
User
demiGod  Offline OP
User

Joined: Mar 2006
Posts: 752
Portugal
Well,

imagine an entity always facing a target, but that entity needs to be always rotating around its y axis or changing its tilt angle..

Re: vec_to_angle and tilt [Re: demiGod] #146941
08/09/07 18:00
08/09/07 18:00
Joined: Jun 2005
Posts: 656
G
Grafton Offline
User
Grafton  Offline
User
G

Joined: Jun 2005
Posts: 656
Do you mean you want to control the tilt manually while the pan always looks at a target?
If so, here is a quick example using the mouse to manually control the tilt:
Code:
  

var tilt_ang;

while(me)
{
vec_set(temp,vecTarget.x);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp);

my.tilt = 0;
tilt_ang += (mouse_force.y * 3) * time_step;
tilt_ang = clamp(tilt_ang, -80, 80); //clamp tilt between 80 and -80 degrees
my.tilt += tilt_ang;

wait(1);
}




You might also want to set the roll to 0 when you set the tilt to 0, or your "my" will roll.



Not two, not one.
Re: vec_to_angle and tilt [Re: Grafton] #146942
08/09/07 18:12
08/09/07 18:12
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline OP
User
demiGod  Offline OP
User

Joined: Mar 2006
Posts: 752
Portugal
Yeap, that´s it very simple, but my head its almost blowing up today..

Thanks Josiah,

Cheers

Re: vec_to_angle and tilt [Re: demiGod] #146943
08/09/07 18:15
08/09/07 18:15
Joined: Jun 2005
Posts: 656
G
Grafton Offline
User
Grafton  Offline
User
G

Joined: Jun 2005
Posts: 656
hehe, I know what you mean, happens to me quite often.

Good luck!


Not two, not one.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | 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