Some basic AI trouble (now w/ a capx)

0 favourites
  • 3 posts
From the Asset Store
Rotate & Animation for 16 Direction & Mouse Direction
  • Hey guys,

    I'm trying to make a game with some simple AI behavior for the Magical Girl Jam. But I'm running into two big problems.

    Firstly, I have an NPC sprite that I'm trying to give some basic AI to. The NPC should move a bit left or right and then pause before moving again. The NPC has four instance variables:

    FSMState (integer; tracks what state the NPC AI is in)

    PauseTime (integer; how many more ticks the NPC should stay still for)

    MoveDirection (integer; -1 if the NPC hasn't decided on a direction to go yet, 1 if the NPC is going left and 0 if the NPC is going right)

    MoveDistance (integer; how many more ticks the NPC should move for)

    When I start up the Store layout, the NPC does not move and just faces right. My event logic for controlling her is in GeneralEvents. If I use debugger mode I can see the variables changing properly, but she never moves.

    Am I doing something wrong? Is there a better supported way to be doing AI stuff? Is this a bug? I don't know! Please tell me.

    My second problem with this project can be best seen in the Test Layout. In it, I have two sprites that have been given the Platforming behavior. One sprite uses my NPC's graphic and the other sprite uses my monster graphic. Below them is a jump through platform sprite. When you start the layout, the two sprites fall towards the platform and then stop on it. However, the monster sprite stops lower than the NPC sprite. This happens no matter what browser I use or what their origins are. The TestGirl and TestMonster objects are exactly the same except for their graphics, so I'm not sure why they're doing this? Perhaps this is a bug?

    Here is a link to a .capx that demonstrates both these problems:

    I'm using r146 64-bit version from Steam if that makes a difference.

    Thank you in advance for advice.

    Edit: Oh. Looks like half my post got eaten when I tried to post initially. Welp... I've fixed it now.

  • For the first problem you need to set MoveDirection to floor(random(2)) to get a 0 or 1. random(2) will give you numbers like 0.695915905746739 which you can see in the debugger.

    For the second you need to fix the sprite collision polygons. That's the area that collides with solids.

    <img src="" border="0" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ah! I can't believe I didn't realize that first one. I'll be sure to put in a floor function later. Thank you for pointing this out.

    For the second, I didn't even know that there were sprite collision polygons! Thank you very very much for informing me of this!

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