Need help with pathfinding + physics

Not favoritedFavorited Favorited 0 favourites
  • 4 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Hello everyone. I have a very interesting idea for creating pathfinding navigation that will use physics for movement (like 'move to,' but without getting stuck or jumping through walls, overlapping, or immovable-movable objects).

    I have made some progress, but my knowledge is not enough to address the following issues:

    The main problem is that enemies chasing the player forget about him instantly if he is not in their view area and stop moving. It would be best to follow the entire path that was calculated and stop only after reaching final destination.

    The secondary problem is tank - vehicle is moving like wet soup on a plate, with no turning radius at all. One of my ideas was to apply a force in the direction between the sprite's current angle/direction and the X and Y direction of the closest node

    How can I improve this? Any ideas or advice would be appreciated

    Here is my C3P file: https://www.dropbox.com/scl/fi/czme98c10ej6cjmvv7gim/Enemy-Pathfinding-Physics-0.5.c3p?rlkey=aalngljdt3tzc9xrgepvrwbz1&st=krrnqdro&dl=0

  • I checked the forum before asking a question to avoid duplicates. Is there something wrong with my question that it was ignored?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Forum is pretty inactive and probably few have suggestions. You can only say you’re being ignored if it’s someone’s job to answer questions I think.

    Anyways, the enemies stop moving since you’re only moving to the first node of the calculated path. You’ll probably want to have it move to each node one by one, and once the enemy is close enough to one node move to the next.

    As for the floaty movement you’d need to calculate different forces to do that. A force to a position generally is always floaty. Intuitively a force perpendicular to the velocity should help it turn faster.

    Or you may be able to throw some math at it to calculate the force required to change the current velocity to another one in one frame.

    Force = K*(TargetVelocity-currentVelocity)*mass*60

    Or split into xy components:

    Forcex=k*(targetvx-currentvx)*mass*60

    Forcey=k*(targetvx-currentvy)*mass*60

    Where k controls how rigid it works. 1 means the velocity changes in one frame, and 0.5 would make it a bit floatier.

    The target velocity would be something like:

    A=angle(enemy.x,enemy.y,node.x,node.y)

    Targetvx=speed*cos(a)

    Targetvy=speed*sin(a)

    You could also try limiting the velocity or force as well. In general you can limit xy values with:

    Mag=distance(0,0,x,y)

    If mag>limit

    — set x to x/mag*limit

    — set y to y/mag*limit

    Anyways, just some ideas.

  • I appreciate the effort that people put in here. Perhaps my question was not clear. I'm sorry if it sounded rude. Thank you very much for your suggestions R0J0hound

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