2 registered members (TipmyPip, 1 invisible),
18,731
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: How to turn the my entity smoothly to a target?
[Re: 3run]
#342610
09/29/10 16:56
09/29/10 16:56
|
Joined: Nov 2003
Posts: 433 The Netherlands
Toon
OP
Senior Member
|
OP
Senior Member
Joined: Nov 2003
Posts: 433
The Netherlands
|
Hey 3run, I love this kind of functions except i can´t write m like that I tried this code:
action test_player()
{
player = me;
}
action test()
{
while(!key_t)
{
wait(1);
}
beep();
wait(-1);
while(1)
{
BotTurnTo(me,player.x);
wait(1);
}
}
But the player entity seems to disappear when i press key_t  Oh the entity does turn in it's direction btw...
|
|
|
Re: How to turn the my entity smoothly to a target?
[Re: 3run]
#343170
10/04/10 07:23
10/04/10 07:23
|
Joined: Dec 2009
Posts: 128 China
frankjiang
Member
|
Member
Joined: Dec 2009
Posts: 128
China
|
about 'target' question. i think target will have much more error for us, 3 months ago, i write any code by vs 2005 , i find 'target' can used by plug-in. in cpp project. who can tell us ,why i uesd 'target' [engine var] ,project will be have any error, so at last time , i also used Lite-C again.
development 3d game is interesting!
|
|
|
Re: How to turn the my entity smoothly to a target?
[Re: Toon]
#343500
10/06/10 18:10
10/06/10 18:10
|
Joined: Sep 2009
Posts: 1,032 Budapest
Aku_Aku
Serious User
|
Serious User
Joined: Sep 2009
Posts: 1,032
Budapest
|
Here is my version, based on that i have found in the manual:
VECTOR* temp1;
function approach_target_angle(ENTITIY* target) {
var sang1, sang2;
int do1, do2;
vec_set(temp1,target.x);
if (NULL != vec_to_screen(temp1,camera)) {
vec_set(temp1,target.x);
vec_to_screen(temp1,camera);
sang1=sign(512-temp1.x)*0.6;
sang2=sign(400-temp1.y)*0.6;
}
else {
camera.tilt=-10;
sang1=1.5;
sang2=0.0;
}
do1=do2=1;
while (do1==1 || do2==1) {
if(temp1.x>515 || temp1.x<505)
camera.pan += sang1;
else
do1=0;
if(temp1.y>405 || temp1.y<395)
camera.tilt += sang2;
else
do2=0;
vec_set(temp1,target.x);
if (NULL != vec_to_screen(temp1,camera)) {
vec_set(temp1,target.x);
vec_to_screen(temp1,camera);
sang1=sign(512-temp1.x)*0.6;
sang2=sign(400-temp1.y)*0.4;
}
else {
camera.tilt=-10;
sang1=1.5;
sang2=0.0;
}
wait(1);
}
}
You can refine or modify the values as you like. sang1 and sang2 values control the speed of the camera moving.
|
|
|
Re: How to turn the my entity smoothly to a target?
[Re: Aku_Aku]
#343501
10/06/10 18:17
10/06/10 18:17
|
Joined: Aug 2009
Posts: 1,438 Spain
painkiller
Serious User
|
Serious User
Joined: Aug 2009
Posts: 1,438
Spain
|
now there is a entmove.c libary which has this function, rotating smoothly and entity to a target
3D Gamestudio A8 Pro AMD FX 8350 4.00 Ghz 16GB RAM Gigabyte GeForce GTX 960 4GB
|
|
|
Re: How to turn the my entity smoothly to a target?
[Re: Aku_Aku]
#343516
10/06/10 19:47
10/06/10 19:47
|
Joined: Aug 2009
Posts: 1,438 Spain
painkiller
Serious User
|
Serious User
Joined: Aug 2009
Posts: 1,438
Spain
|
I think it was added in the first version of A8
3D Gamestudio A8 Pro AMD FX 8350 4.00 Ghz 16GB RAM Gigabyte GeForce GTX 960 4GB
|
|
|
|