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
3 registered members (AndrewAMD, Ayumi, NewbieZorro), 14,141 guests, and 5 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
Page 2 of 2 1 2
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
T
Toon Offline OP
Senior Member
Toon  Offline OP
Senior Member
T

Joined: Nov 2003
Posts: 433
The Netherlands
Hey 3run, I love this kind of functions except i can´t write m like that tongue

I tried this code:

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 grin Oh the entity does turn in it's direction btw...

Re: How to turn the my entity smoothly to a target? [Re: Toon] #342792
10/01/10 07:27
10/01/10 07:27
Joined: May 2009
Posts: 5,377
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,377
Caucasus
Not tested, but try this one:
Code:
VECTOR temp;

int BotTurnTo(ENTITY* ent,VECTOR* targ_vec)
{
	vec_set(temp,targ_vec.x); 
	vec_sub(temp,ent.x); 
	vec_to_angle(ent.pan, temp);
}

action test_player()
{    
    player = me;
}

action test()
{
    while(!key_t)
    {
        wait(1);
    }
    beep();
    wait(-1);
    while(1)
    {
        BotTurnTo(me,player.x);
        wait(1);
    }
}




Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: How to turn the my entity smoothly to a target? [Re: 3run] #342879
10/01/10 19:03
10/01/10 19:03
Joined: May 2009
Posts: 5,377
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,377
Caucasus
Here is the example, not made by me, but by my friend:
Code:
VECTOR temp;

ANGLE temp_angle;

function BotTurnTo(ENTITY* ent,VECTOR* targ_vec,var turning_spd)
{
	vec_set(temp,targ_vec.x);
	vec_sub(temp,ent.x); 
	vec_to_angle(temp_angle,temp);
	if(ang(temp_angle.pan - ent.pan) < -1 | ang(temp_angle.pan - ent.pan) > 1)
	{
		ent.pan += sign(ang(temp_angle.pan - ent.pan)) * 10 * time_step ;
	}	
	ent.tilt = 0;
	ent.roll = 0;
}


Sorry for double post wink


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
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 Offline
Member
frankjiang  Offline
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 Offline
Serious User
Aku_Aku  Offline
Serious User

Joined: Sep 2009
Posts: 1,032
Budapest
Here is my version, based on that i have found in the manual:
Code:
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 Offline
Serious User
painkiller  Offline
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: painkiller] #343503
10/06/10 18:23
10/06/10 18:23
Joined: Sep 2009
Posts: 1,032
Budapest
Aku_Aku Offline
Serious User
Aku_Aku  Offline
Serious User

Joined: Sep 2009
Posts: 1,032
Budapest
Is it also in A6 and A7 editions?

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 Offline
Serious User
painkiller  Offline
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
Page 2 of 2 1 2

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