How do I set a position for move to pathfinding. as a circle around the point?

0 favourites
  • 4 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • im moving to a sprite, but the spite has a 3d object over it. so, when pathfinding, its taking a longer route to what it deems as the best way.

    i would like to have a distance check

    i.e:

    set path to x= tile.x (+or- the radius to a closest point of the circumference)

    hope that makes sense. probably there is a sin function for it... ? or ill have to bust open some math research if no one has a script made

  • C⃗ =A⃗ +r(B⃗ −A⃗ )||B⃗ −A⃗ ||

    Where r

    is the radius of the circle. Works for points both inside and outside the circle. Imagine (B⃗ −A⃗ )

    to be a vector in the direction of B⃗

    and (B⃗ −A⃗ )||B⃗ −A⃗ ||

    thus is the same vector but with a length of 1

    . By multiplying it with r

    , you "walk in that direction" a total distance of r

    , thus reaching the circle.

    With coordinats A⃗ =(Ax,Ay)

    etc. this reads

    Cx=Ax+rBx−Ax(Bx−Ax)2+(By−Ay)2−−−−−−−−−−−−−−−−−−−−√

    Cy=Ay+rBy−Ay(Bx−Ax)2+(By−Ay)2−−−−−−−−−−−−−−−−−−−−√

    ooh boy... this will be fun

  • yea, ok. actually not that bad.

    C is the point on the circle you want to get

    A is the sprite

    B is what will move

    R is the radius

    C.y= A.y+R((B.y-A.y)/√((B.x-A.x)^2+(B.y-A.y)^2)

    thought id update my post with an answer if others search for it

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • C.x= A.x+R((B.x-A.x)/√((B.x-A.x)^2+(B.y-A.y)^2)

    for the X

    wow, it works beautifully and smoothly

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)