Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,135 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 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,439
Red Dwarf
Michael_Schwarz Offline
Senior Expert
Michael_Schwarz  Offline
Senior Expert

Joined: Aug 2003
Posts: 7,439
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 | 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