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
1 registered members (TipmyPip), 18,618 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
Movement curve #230855
10/09/08 13:09
10/09/08 13:09
Joined: Aug 2006
Posts: 652
Netherlands
bstudio Offline OP
User
bstudio  Offline OP
User

Joined: Aug 2006
Posts: 652
Netherlands
So...

To state an example:
I have a player and an enemy. The enemy needs to move towards the player, but I don't want to do this in a straight line. So I want his "path" to curve a bit (illustrated by the following picture)



The black line is what I want. I looked at some tutorials about interpolation, but couldn't really figure it out. Some psudo code or something to get me started would be greatly appreciated smile

b-studio


BASIC programmers never die, they GOSUB and don't RETURN.
Re: Movement curve [Re: bstudio] #230861
10/09/08 13:54
10/09/08 13:54
Joined: Aug 2003
Posts: 7,440
Red Dwarf
Michael_Schwarz Offline
Senior Expert
Michael_Schwarz  Offline
Senior Expert

Joined: Aug 2003
Posts: 7,440
Red Dwarf
well, you will need to work with cos() and sin() but don't ask me any further. I'm no maths mayor wink

maybe just try around a bit, or wait until someone comes by who didnt fail math laugh


"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku
Re: Movement curve [Re: Michael_Schwarz] #230865
10/09/08 14:46
10/09/08 14:46
Joined: Feb 2008
Posts: 337
V
Vadim647 Offline
Senior Member
Vadim647  Offline
Senior Member
V

Joined: Feb 2008
Posts: 337
let's think about it...
Basic is (x is movement towards direction, y is horizontal offset)
x = position
y = cos(position/distance*180)
Usage of vec_rotate can do other things.


I switched to other account since marth 2010. Guess which.
Re: Movement curve [Re: Vadim647] #230869
10/09/08 16:53
10/09/08 16:53
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
I would let the enemy face the player, then add a slight deviation off from the player (doesn't need to be the facing direction, only the movement direction, so he sort of strives sideways), and shrink this deviation to 0 when the enemy approaches the player.


Click and join the 3dgs irc community!
Room: #3dgs
Re: Movement curve [Re: Joozey] #230923
10/10/08 07:29
10/10/08 07:29
Joined: Aug 2006
Posts: 652
Netherlands
bstudio Offline OP
User
bstudio  Offline OP
User

Joined: Aug 2006
Posts: 652
Netherlands
Thanks for your help, I'll check if I can make it work smile


BASIC programmers never die, they GOSUB and don't RETURN.

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