How do I make my follower have higher intelligence and able to walk through on collision?

0 favourites
  • 12 posts
From the Asset Store
Players follower. use it for anything which follows the player
  • proj: drive.google.com/file/d/11yitalb_CWbsxo47kkuHVdNNK_fpXebZ/view

    (for some reason I can't share screenshots.)

    I'll just copy some of the code.

    [every_tick]

    ----+ System: Every tick

    | Local number dist‎ = 0

    | Local number ang‎ = 0

    --------+ (no conditions)

    ---------> System: Set ang to angle(SPR_FOLLOWER.X, SPR_FOLLOWER.Y, PLAYER_BASE.X, PLAYER_BASE.Y)

    ---------> System: Set dist to distance(SPR_FOLLOWER.X, SPR_FOLLOWER.Y, PLAYER_BASE.X, PLAYER_BASE.Y)

    --------+ System: dist > 30

    ---------> SPR_FOLLOWER: Set 8Direction vector X to (dist-30)×cos(ang)×2

    ---------> SPR_FOLLOWER: Set 8Direction vector Y to (dist-30)×sin(ang)×2

    ----+ System: Every tick

    -----> PLAYER_MASK: Set position to (PLAYER_BASE.X, PLAYER_BASE.Y - 20)

    ----+ System: Every tick

    -----> FOLLOWER_MASK: Set position to (SPR_FOLLOWER.X, SPR_FOLLOWER.Y - 20)

    [follower]

    ----+ Keyboard: ↑ is down

    --------+ Keyboard: [X] ↓ is down

    ---------> FOLLOWER_MASK: Set Walking to True

    --------+ Keyboard: [X] ← is down

    --------+ Keyboard: [X] → is down

    ---------> FOLLOWER_MASK: Set Direction to "Up"

    ----+ Keyboard: ↓ is down

    --------+ Keyboard: [X] ↑ is down

    ---------> FOLLOWER_MASK: Set Walking to True

    --------+ Keyboard: [X] ← is down

    --------+ Keyboard: [X] → is down

    ---------> FOLLOWER_MASK: Set Direction to "Down"

    ----+ Keyboard: → is down

    --------+ Keyboard: [X] ← is down

    ---------> FOLLOWER_MASK: Set Walking to True

    --------+ Keyboard: [X] ↓ is down

    --------+ Keyboard: [X] ↑ is down

    ---------> FOLLOWER_MASK: Set Direction to "Right"

    ----+ Keyboard: ← is down

    --------+ Keyboard: [X] → is down

    ---------> FOLLOWER_MASK: Set Walking to True

    --------+ Keyboard: [X] ↓ is down

    --------+ Keyboard: [X] ↑ is down

    ---------> FOLLOWER_MASK: Set Direction to "Left"

    ----+ PLAYER_MASK: [X] Is Attacking

    --------+ PLAYER_MASK: Is Walking

    ---------> FOLLOWER_MASK: Set animation to "Walk_" & Self.Direction (play from beginning)

    --------+ PLAYER_MASK: [X] Is Walking

    ---------> FOLLOWER_MASK: Set animation to "Idle_" & Self.Direction (play from beginning)

    [general]

    ----+ Keyboard: [X] ↑ is down

    ----+ Keyboard: [X] ↓ is down

    ----+ Keyboard: [X] → is down

    ----+ Keyboard: [X] ← is down

    -----> PLAYER_MASK: Set Walking to False

    -----> FOLLOWER_MASK: Set Walking to False

  • More specifically, how would I make the follower's collision disable ONLY when the player walks in it's collision box

  • How about collision filtering, where the player ignores the follower's collision box entirely, while keeping the follower collision box enabled all the time?

  • How about collision filtering, where the player ignores the follower's collision box entirely, while keeping the follower collision box enabled all the time?

    Figured it out! Now all I need to do is figure out how to make the follower move around walls instead of getting stuck on them. Is there a simple way to do this?

  • Usually pathfinding behaviour would be used instead of the way you implemented it. Not sure what you expect to happen if you designed it in a way where pressing right also makes him move right.

  • There is an example in Construct for followers

    editor.construct.net

  • Usually pathfinding behaviour would be used instead of the way you implemented it. Not sure what you expect to happen if you designed it in a way where pressing right also makes him move right.

    Ohh okay, is there any tutorials related to followers & pathfinding?

  • There is an example in Construct for followers

    https://editor.construct.net/#open=follow-path

    Thanks, but this isn't exactly what I'm looking for. I'm looking for a top down pathfind based follower. I can't seem to find any tutorials about it.

  • If you don't want the follower to cut corners and get stuck, there are a few options to try:

    1. Use pathfinding.

    2. Have the player drop or otherwise keep track of waypoints for the follower, so the follower follows the player's path exactly and doesn't cut corners.

    3. Use line of sight to trigger a switch over to pathfinding when line of sight is lost, until line of sight is regained.

  • The follower example will work fine for top down also.

    Check this out

    1drv.ms/u/s!AkmrWgxeuxlKhJt3WmqcgENIJIKQRg

  • If you don't want the follower to cut corners and get stuck, there are a few options to try:

    1. Use pathfinding.

    2. Have the player drop or otherwise keep track of waypoints for the follower, so the follower follows the player's path exactly and doesn't cut corners.

    3. Use line of sight to trigger a switch over to pathfinding when line of sight is lost, until line of sight is regained.

    Awesome ideas. I'll try them all out tomorrow and get back to you. Thank you!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The follower example will work fine for top down also.

    Check this out

    https://1drv.ms/u/s!AkmrWgxeuxlKhJt3WmqcgENIJIKQRg?e=kSffcY

    Thanks!

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