How do i make an enemy npc have a fixed path?

0 favourites
From the Asset Store
Fantasy RPG Human-NPC assets pack of 15 characters
  • Hello there. I am very new to C2 and I need help with my NPCs.

    I am currently making a Top Down View game with 4 direction on my characters. I need urgent help with trying to make the NPC follow a fixed path so if anyone knows how to do this, help would be much appreciated?

    Also I want the character to animate as it moves in each direction. For instance, when my enemy goes right, the right animation would play to make it look like he walks, and when he goes left again back to the original position the left animation plays. Thank you.

    Also if you open my game file you can see i have security cameras but the animation is jumping. How would i make this go smooth from side to side?

  • Security cameras: Animations aren't the best way to go here. Instead, have one frame where your camera is pointing to the right and the origin is in the middle of the camera itself, then use the Sine behavior on that object to alter its angle. There are a lot of settings there where you can change how far it turns, how fast, etc.

    Path movement: There are a lot of ways you can do this. One simple way is outlined below:

    1. Give the enemy the CustomMovement behavior(remove the pin behavior, too).

    2. Have four invisible sprites representing up, down, left, and right.

    3. Give the enemy some intial speed through the custom movement.

    4. When the enemy collides with one of the direction sprites, adjust his speed to move in the associated direction.

    5. Place your direction sprites such that your enemy will essentially "bounce" from one to the next until he finds his way to the original position, at which point he starts all over again.

    There are ways to achieve more complex path movements, and ways to do it using fewer direction sprites, but I feel this provides a good visual explanation of one method.

  • hi, can someone please do the events for me for my npc police enemy cause im finding it impossible. Please!!!

  • I need help with making my enemy police following a simple path going left and right and playing the animations as he goes in this direction. I would need it to loop please. help pleaseeeeeeeeeeeeee guys

  • Security cameras: Animations aren't the best way to go here. Instead, have one frame where your camera is pointing to the right and the origin is in the middle of the camera itself, then use the Sine behavior on that object to alter its angle. There are a lot of settings there where you can change how far it turns, how fast, etc.

    Path movement: There are a lot of ways you can do this. One simple way is outlined below:

    1. Give the enemy the CustomMovement behavior(remove the pin behavior, too).

    2. Have four invisible sprites representing up, down, left, and right.

    3. Give the enemy some intial speed through the custom movement.

    4. When the enemy collides with one of the direction sprites, adjust his speed to move in the associated direction.

    5. Place your direction sprites such that your enemy will essentially "bounce" from one to the next until he finds his way to the original position, at which point he starts all over again.

    There are ways to achieve more complex path movements, and ways to do it using fewer direction sprites, but I feel this provides a good visual explanation of one method.

    Thanks for the feedback but im still confused. Im new to this program. Could you please be more specific or even do it for me?

  • I added bullet behaviour & disable sine behaviour

  • Hey!

    I added a sprite (policeGuide) which has a variable (direction) just position then at places you need the cop to turn and set the variable to the direction towards which he should turn. I positioned some of them at the intersections, so the cop is already making a circuit if you check it, but you may remove them and program your own circuit. Note the guides are transparent, though.

    [attachment=0:q39pjozd][/attachment:q39pjozd]

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey!

    I added a sprite (policeGuide) which has a variable (direction) just position then at places you need the cop to turn and set the variable to the direction towards which he should turn. I positioned some of them at the intersections, so the cop is already making a circuit if you check it, but you may remove them and program your own circuit. Note the guides are transparent, though.

    [attachment=0:2qat1m2a][/attachment:2qat1m2a]

    Thank you so much!

  • Hey!

    I added a sprite (policeGuide) which has a variable (direction) just position then at places you need the cop to turn and set the variable to the direction towards which he should turn. I positioned some of them at the intersections, so the cop is already making a circuit if you check it, but you may remove them and program your own circuit. Note the guides are transparent, though.

    [attachment=0:4v3b8ai4][/attachment:4v3b8ai4]

    How do i make more police in the game quickly?

  • Just add them multiple times. Not sure what you meant...

  • Just add them multiple times. Not sure what you meant...

    Let me rephrase that. Can i copy and paste the policeanimations and make new paths for each one or do i have to add the police animations sprite again and make a new police guide for each police sprite i add?

  • The police and policeanimation objects will all react to any policeguide they find. If you want them to be specific, you should add the police Id as a variable to the policeGuide and check if they match.

  • The police and policeanimation objects will all react to any policeguide they find. If you want them to be specific, you should add the police Id as a variable to the policeGuide and check if they match.

    I just tried that my friend and it didnt seem to work? im not sure if im doing it wrong or not?

  • The police and policeanimation objects will all react to any policeguide they find. If you want them to be specific, you should add the police Id as a variable to the policeGuide and check if they match.

    If you dont mind making another police follow a different route from the copy you gave earlier just so i can follow the things and do a load more characters. it would be much appreciated

  • Hey. Today is release day at the studio, so I'm a little too busy. I'll try to make a demo when I get home tonight, ok?

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