Gamestudio Links
Zorro Links
Newest Posts
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
1 registered members (AndrewAMD), 1,310 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 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 | 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