Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
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
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
smooth turn #158362
10/03/07 04:48
10/03/07 04:48
Joined: Jun 2003
Posts: 261
Broken Arrow ,OK
BERG Offline OP
Member
BERG  Offline OP
Member

Joined: Jun 2003
Posts: 261
Broken Arrow ,OK
Whats the best way to have te player turn smoothly towards a target (that i clicked on) and move to it?

this is the code i have inside a loop :

Code:
 
if(vec_dist(my.x,new_pos)>50)
{my_speed2.x=4;
vec_set(temp,vector(new_pos.x,new_pos.y,my.z));
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp);

ent_move(my_speed2,nullvector);
}




it turns the player to the target immediately instead of in incrememnts.

however, i did try to set the vec to angle pan to another variable ad then if my pan as greater than the target pan it would rotate left an incrememnt and vice versa. but it looks clunky and sometimes the player will miss the target and go turn back and forth.

please help,
Alex

Re: smooth turn [Re: BERG] #158363
10/03/07 07:11
10/03/07 07:11
Joined: Aug 2006
Posts: 152
vector(200,45,338)
Marwan Offline
Member
Marwan  Offline
Member

Joined: Aug 2006
Posts: 152
vector(200,45,338)


age:16 game design and programming experience:2 years
Re: smooth turn [Re: Marwan] #158364
10/04/07 19:09
10/04/07 19:09
Joined: Jun 2003
Posts: 261
Broken Arrow ,OK
BERG Offline OP
Member
BERG  Offline OP
Member

Joined: Jun 2003
Posts: 261
Broken Arrow ,OK
haha i tried that, but as i said before te player misses te target if its too close. how ever, i could write the varying speed as a function of distance. lets see how that goes!

Re: smooth turn [Re: BERG] #158365
10/04/07 19:36
10/04/07 19:36
Joined: Jun 2003
Posts: 261
Broken Arrow ,OK
BERG Offline OP
Member
BERG  Offline OP
Member

Joined: Jun 2003
Posts: 261
Broken Arrow ,OK
here we go:
Code:


while(vec_dist(new_pos,my.x)>20)
{
...
vec_set(temp,vector(new_pos.x,new_pos.y,my.z));

vec_sub(temp,my.x);

vec_to_angle(new_pan.pan,temp);// new_pan.pan is the value holder

my.pan+=(new_pan.pan-my.pan)/20 //"20" is te slow down factor. set it to 1 and the player will turn towards the target immediately.
...
}






Re: smooth turn [Re: BERG] #158366
10/04/07 19:41
10/04/07 19:41
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl
dont know if you means this but you cn try it

Code:

var rotate;
var speed =2;
if(vec_dist(my.x,new_pos)>50)
{my_speed2.x=4;
vec_set(temp,vector(new_pos.x,new_pos.y,my.z));
vec_sub(temp,my.x);
vec_to_angle(rotate,temp);
my.pan = (rotate / rotate)*speed*time_step;
ent_move(my_speed2,nullvector);
}




"empty"
Re: smooth turn [Re: flits] #158367
10/09/07 03:40
10/09/07 03:40
Joined: Jun 2003
Posts: 261
Broken Arrow ,OK
BERG Offline OP
Member
BERG  Offline OP
Member

Joined: Jun 2003
Posts: 261
Broken Arrow ,OK
rotate/rotate? doesnt that give u one?


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