Discuss Scratch

acumoo
Scratcher
4 posts

Making a sprite walk in a line with AI

I am making a game and I wanted to make a pathfinding AI for it. The issue is it isn't in a grid so I think if I can make sprites walk in a line it can work. How can I make a sprite walk in a line? Is it posibble?
WildTraces
Scratcher
100+ posts

Making a sprite walk in a line with AI

Do you mean following a pre-drawn line or just moving straight?
acumoo
Scratcher
4 posts

Making a sprite walk in a line with AI

WildTraces wrote:

Do you mean following a pre-drawn line or just moving straight?
I meant a pre-drawn line like drawn by a pen. I know how to make sprites go straight to another sprite

Last edited by acumoo (June 1, 2020 13:17:38)

WildTraces
Scratcher
100+ posts

Making a sprite walk in a line with AI

Does it know the coordinate of the start and end of the line or not. If not then use:

when green flag clicked
forever
if <touching color [#000000] ?> then
turn ccw (2) degrees
else
turn cw (2) degrees
end
move (pick random (0.9) to (1.1)) steps
end

Last edited by WildTraces (June 1, 2020 13:18:54)

WildTraces
Scratcher
100+ posts

Making a sprite walk in a line with AI

If you know the coordinates of a straight line then you can use trig to work out the angle to face then just move straight. For a curve it is more difficult, esp if you need it to move a constant speed.
WildTraces
Scratcher
100+ posts

Making a sprite walk in a line with AI

Powered by DjangoBB