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
2 registered members (AndrewAMD, TipmyPip), 13,557 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
Goto Position #288435
09/06/09 10:30
09/06/09 10:30
Joined: May 2006
Posts: 133
ME
Mysterious Offline OP
Member
Mysterious  Offline OP
Member

Joined: May 2006
Posts: 133
ME
Hi
I am wondering what is the best practice to make an Entity following another movable Entity ?

thanks

Re: Goto Position [Re: Mysterious] #288467
09/06/09 18:01
09/06/09 18:01
Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
Cowabanga Offline
Expert
Cowabanga  Offline
Expert

Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
Try something like this:

Code:
while(1)
{
	my.x = entity.x - 50;
	my.y = entity.y;
	my.pan = entity.pan;
}



Re: Goto Position [Re: Cowabanga] #288471
09/06/09 18:14
09/06/09 18:14
Joined: Jan 2008
Posts: 34
Fab4 Offline
Newbie
Fab4  Offline
Newbie

Joined: Jan 2008
Posts: 34
I wouldn't do it this way...
calculate the distance between the two objects

sqrt(pow(player.x-my.x,2)+pow(player.y-my.y,2))


and let him look at the player.
if the distance is bigger than (for example) 20 make him move until the distance is smaller than for example 10 make him stop.

you will only have a problem with obstacles.

edit:
tell me if you need a code for this.

Last edited by Fab4; 09/06/09 18:29.
Re: Goto Position [Re: Fab4] #288472
09/06/09 18:29
09/06/09 18:29
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Originally Posted By: Fab4
I wouldn't do it this way...
calculate the distance between the two object
sqrt(pow(player.x-my.x,2)+pow(player.y-my.y,2))


The vec_dist function does this for you.

Re: Goto Position [Re: DJBMASTER] #288534
09/07/09 04:59
09/07/09 04:59
Joined: May 2006
Posts: 133
ME
Mysterious Offline OP
Member
Mysterious  Offline OP
Member

Joined: May 2006
Posts: 133
ME
Thanks all

@Fab4
I don't care about obstacles
well, a piece of code will be nice
thanks for your time

actually I want the camera to follow the player (something like Prince of Persia camera)


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