0 registered members (),
1,209
guests, and 0
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: How i can make to a entity turn to face player
[Re: JackTheRipper]
#105494
01/05/07 19:43
01/05/07 19:43
|
Joined: Jan 2006
Posts: 53
LWD
OP
Junior Member
|
OP
Junior Member
Joined: Jan 2006
Posts: 53
|
It works fine, thanks to all! But when i press key_e the entity turns very fast, have a way to change de speed that the entity rotate? Thanks!
Last edited by LWD; 01/05/07 19:45.
|
|
|
Re: How i can make to a entity turn to face player
[Re: LWD]
#105495
01/05/07 20:05
01/05/07 20:05
|
Joined: Dec 2005
Posts: 252 MyOwnKingdom
nipx
Member
|
Member
Joined: Dec 2005
Posts: 252
MyOwnKingdom
|
With vec_to_angle(my.pan, temp); you set the new angle (pan) directly. If you want to turn it use c_rotate. --->> Save the new angle. Code:
//create new vector to store angles var vecAngle[3]
-> vec_to_angle(vecAngle, temp);
then calculate the difference between the angle the enemy has now and the one he should turn to. Code:
//get diff between current angle and the needed vec_diff(temp, vecAngle, my.pan);
then turn your enemy Code:
c_rotate(me, temp, glide);
I didnt test it but it should work. nipx
|
|
|
Re: How i can make to a entity turn to face player
[Re: nipx]
#105496
01/05/07 20:19
01/05/07 20:19
|
Joined: Jan 2006
Posts: 53
LWD
OP
Junior Member
|
OP
Junior Member
Joined: Jan 2006
Posts: 53
|
I did not understand... How i can apply this code to the old code? I substitute the old code: vec_set(temp, player.x); vec_sub(temp, my.x); vec_to_angle(my.pan, temp); for the new: var vecAngle[3] vec_diff(temp, vecAngle, my.pan); c_rotate(me, temp, glide);
and the entity turns to left, and not to the player... Thanks!
Last edited by LWD; 01/05/07 20:21.
|
|
|
Re: How i can make to a entity turn to face player
[Re: nipx]
#105500
01/05/07 21:26
01/05/07 21:26
|
Joined: Jan 2006
Posts: 53
LWD
OP
Junior Member
|
OP
Junior Member
Joined: Jan 2006
Posts: 53
|
Thanks a lot! I just made a change in the order of the lines of you code and it works fine! Thanhs to all!!!
Last edited by LWD; 01/05/07 21:43.
|
|
|
Re: How i can make to a entity turn to face player
[Re: LWD]
#105501
01/05/07 21:44
01/05/07 21:44
|
Joined: Dec 2005
Posts: 252 MyOwnKingdom
nipx
Member
|
Member
Joined: Dec 2005
Posts: 252
MyOwnKingdom
|
try this: Code:
//scale vector, make it slower vec_scale(temp,(Scale *time_step));
//calculate how many times to rotate when vector is scaled tmpCounter= Scale *time_step ;
while(counter < tmpCounter) { c_rotate(me, temp, glide); counter+=1; wait(1); }
edit: if it works now you still should include time_step in your code otherwise the rotation wont be smooth
Last edited by nipx; 01/05/07 22:03.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|