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
0 registered members (), 947 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
Camera to "SLOWLY" turn towards target #293318
10/10/09 17:46
10/10/09 17:46
Joined: Apr 2006
Posts: 28
LB, CA, USA
WINBERRY Offline OP
Newbie
WINBERRY  Offline OP
Newbie

Joined: Apr 2006
Posts: 28
LB, CA, USA
I've been trying to get my camera to 1) find a target then 2) slowing pan over until that target is center screen then 3) slowly move towards target.

I've tried c_trace to find the target then vec_to_angle to look at target, however, vec_to_angel turns the camera instantly.

Any way to turn the camera towards a target, slow and easy?

Thanks in advance for your input
winberry.com

Re: Camera to "SLOWLY" turn towards target [Re: WINBERRY] #293332
10/10/09 18:48
10/10/09 18:48
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Code:
...TARGET = get the vector of your target.  eg. you.x
...SPEED  = set the speed of turning in 'degrees per frame'
//get TARGET's direction from ME
VECTOR pos, temp;	vec_set(pos.x, TARGET.x); 	
vec_to_angle(temp.x, vec_sub(pos.x, my.x));		
//calculate the 'difference' from MY current direction
vec_sub(temp.x, my.pan);	
//limit 'difference' change-per-frame
vec_set(temp.x, vector( clamp(ang(temp.x), -SPEED, SPEED), 0, 0));
vec_scale(temp.x, time_step);	vec_add(my.pan, temp.x);		
...
///




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Camera to "SLOWLY" turn towards target [Re: EvilSOB] #293440
10/11/09 14:28
10/11/09 14:28
Joined: Apr 2006
Posts: 28
LB, CA, USA
WINBERRY Offline OP
Newbie
WINBERRY  Offline OP
Newbie

Joined: Apr 2006
Posts: 28
LB, CA, USA
EvilSOD,
Thanks for your response.
What you offered might be to far over my head, but this is what I put together:

function test()
{
var SPEED = 1;
//TARGET = get the vector of your target. eg. you.x
c_trace(holdIMAGE.x,camera.pan,ACTIVATE_SONAR);
//SPEED = set the speed of turning in 'degrees per frame'
//get TARGET's direction from ME

VECTOR pos, temp;
vec_set(pos.x, target.x);
//vec_to_angle(temp.x, vec_sub(pos.x, holdIMAGE.x));
vec_to_angle(camera.pan,vec_diff(NULL,holdIMAGE.x,camera.x));
//calculate the 'difference' from MY current direction
vec_sub(temp.x, camera.x);
//limit 'difference' change-per-frame
vec_set(temp.x, vector( clamp(ang(temp.x), -SPEED, SPEED), 0, 0));
//vec_scale(temp.x, time_step);
vec_add(camera.pan, temp.x);
wait(1);

}
This test() will zip me to the target image,
(holdIMAGE is the vector of the media_loop sprite which is an ENTITY, but not a you(? every time I tried it with you it would crash))


...but when I tried to put a 'while' statement to slow the turn down, it just kept spinning

function test_with_while()
{
var SPEED = 1;
//TARGET = get the vector of your target. eg. you.x
c_trace(holdIMAGE.x,camera.pan,ACTIVATE_SONAR);
//SPEED = set the speed of turning in 'degrees per frame'
//get TARGET's direction from ME

while(holdIMAGE.x != camera.x){
VECTOR pos, temp;
vec_set(pos.x, target.x);
//vec_to_angle(temp.x, vec_sub(pos.x, holdIMAGE.x));
vec_to_angle(camera.pan,vec_diff(NULL,holdIMAGE.x,camera.x));
//calculate the 'difference' from MY current direction
vec_sub(temp.x, camera.x);
//limit 'difference' change-per-frame
vec_set(temp.x, vector( clamp(ang(temp.x), -SPEED, SPEED), 0, 0));
//vec_scale(temp.x, time_step);
vec_add(camera.pan, temp.x);
wait(1);
}

}

If you have any sujestions on what I'm missing here, pleae offer, otherwise, thanks again for your input.

WINBERRY

Re: Camera to "SLOWLY" turn towards target [Re: WINBERRY] #293467
10/11/09 18:04
10/11/09 18:04
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Try this one instead then, sorry this code is un-tested, I dont have much time at ATM.

Code:
function test()
{ 
   var SPEED = 1;   //set the speed of turning in 'degrees per frame' 
   ANGLE temp; 
   while(holdIMAGE!=NULL){
      vec_set(temp, holdIMAGE.x); 	
      vec_to_angle(temp, vec_sub(temp, camera.x));		
      vec_sub(temp, camera.pan);	
      temp.pan  = clamp(ang(temp.pan ), -SPEED, SPEED);
      vec_add(camera.pan, temp);		
      wait(1); 
   }
}




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Camera to "SLOWLY" turn towards target [Re: EvilSOB] #293501
10/11/09 22:50
10/11/09 22:50
Joined: Apr 2006
Posts: 28
LB, CA, USA
WINBERRY Offline OP
Newbie
WINBERRY  Offline OP
Newbie

Joined: Apr 2006
Posts: 28
LB, CA, USA
WOW!!!

Thank you VERY much..that's fantastic!
I hope I can return the favor some day

Winberry.com

Re: Camera to "SLOWLY" turn towards target [Re: WINBERRY] #293520
10/12/09 06:13
10/12/09 06:13
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
no problem, glad to have been of help...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial

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