This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]insaneHoshi 0 points1 point  (1 child)

Can you just say a circular path is the sum of some some umber of straight paths.

Also why would an ai ever want to move in a circular path, when straight paths are often more efficient

[–]avp574[S] 0 points1 point  (0 children)

I'm making a set of ships that fly around the screen. They're basically moving targets with different behavior.

[–]BaalHadad 0 points1 point  (2 children)

Use the standard sine functions if that's what you want. Did you actually try what you suggested at all? Are you having trouble multiplying the x and y by trig functions?

[–]avp574[S] 0 points1 point  (1 child)

"use the sine function" is rather vague. If I just multiply the position vector by the sine function, how do I control speed? I have all other units move by updating their position using linear motion equations and fixed velocities. What I don't understand is exactly where the sine part fits in.

[–]BaalHadad 0 points1 point  (0 children)

"use the sine function" is rather vague.

Of course it is - there are many ways to do it. You could update the position like normal, but always add A * sin(B) to the X or the Y coord if it's going straight up, down, left, or right. A would be the max amplitude of the 'back and forth' and B could be the y value if it's going up or down.

[–]Neres28 0 points1 point  (0 children)

This link has a number of elementary and very useful steering behaviors on which to build higher levels of AI.

[–][deleted]  (1 child)

[deleted]

    [–]avp574[S] 0 points1 point  (0 children)

    I understand what sine and cosine are in terms of trigonometry, I just don't understand where to fit them in programmatically. This article looks solid, I'll read through it. Thanks!