JumbocactuarX27's Forum Posts

  • 8 posts
  • 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!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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: dl.dropboxusercontent.com/u/8404998/CantGetAIToWork.capx

    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.

  • This is best done with an invisible detector (left not-so-invisible so you can see it for this example).

    http://blackhornettechnologies.com/Construct2Stuff/CarSelfDetection_invisibledetector.capx

    Oh snap! Thanks Blackhornet! This is exactly what I needed.

    Looking over the project you uploaded, I think my problems were that I wasn't understanding entirely how the "Pick" conditions worked and I didn't even think about using UIDs like that. I'll go read up on these features more now.

    Thank you very much, again.

  • megatronx,

    I checked out those .capx files you linked me and while they were informative, they haven't led me to a solution for my problem. Although they did make me learn about Families, so that was good. Thanks.

    Upon reflection, I was thinking that maybe my initial test project wasn't representative enough of what I want to accomplish, so I've replaced it with a new one which is much more in line with what I'm trying to do.

    Download it here: dropbox.com/s/lrxpi6ym5niysf0/CarSelfDetection.capx

    If you can't download it, here's some screenshots.

    Layout (The car facing left is the one which accelerates)

    <img src="http://i.imgur.com/6Ke1LTF.png" border="0" />

    Event Sheet

    <img src="http://i.imgur.com/GyWJKFS.png" border="0" />

    Basically, there's a bunch of cars and one of them starts to accelerate (instance variable crashed == false). Every tick, for each car in the layout, I check the area in front of the car and if it is not overlapping another car at offset then I accelerate. If there is a car detected then I stop. Unfortunately, as you can see if you run the project, the car does not stop.

    How do I make the car stop?

  • I had this problem some time ago.

    Here are 3 examples I've found on the forums. Should help.

    https://app.box.com/s/yf102y7q0l97qvczsilz

    Thanks, I'm at work right now, but I'll check these when I get home.

    No, I use this same thing with Player.X and Y. It doesn't have to be stationary at all.

    One other way you can do it is to pin a invisible sprite to the car and when that sprite collides with an object, register the detection (think of it as "line of sight" detection)

    I think that perhaps I have explained my problem improperly. I have a bunch of instances of the same object (in this case a car) on my layout and I want to know when one of them is in front of the other. It is not the player and there's say, 100 of them around at all times. To the best of my knowledge, I can't pin an invisible sprite to each of them (using event code) to use that to check for collisions. If I can, that would be great though. How do I pin 100 invisible sprites to 100 cars though?

  • Right, but your DestinationX/Y are stationary. I'm looking for any car sprite that is near any other car sprite in one specific direction (Sprite.Angle in this case).

    Unless I'm mistaken your solution won't solve my problem.

  • I'm having trouble figuring out how to get an object to detect another object of the same type at an offset. Here's a test project I've set up to show my problem, hopefully I'm making some dumb and obvious mistake here.

    Event page:

    i.imgur.com/sRKfZJR.png

    Layout:

    i.imgur.com/LzvY9i9.png

    So my goal here is to get each instance of the car sprite object to notice when something is in front of it so that it can react accordingly. I'm going to have a lot of these sprites in my game at once, so it'd be nice if I didn't have to compute distance between all of them each tick. I thought the overlaps on offset was perfect, but I guess not?

    Another point, in my real project file, the sprites seem to react to a second object (which is why I included the 'cone' sprite) but here it doesn't seem to register it? Though if I enable the action on the event page that moves the cone, it gets detected just fine.

    I've been wrestling with this for a while and I'm just not sure if I'm doing it the wrong way or what. Can someone please give me some suggestions?

    Here's a link to the .capx that the pictures came from: dropbox.com/s/lrxpi6ym5niysf0/CarSelfDetection.capx

  • Link to .capx file (required!):

    dl.dropboxusercontent.com/u/8404998/Error%20Project/ErrorProject.capx

    Steps to reproduce:

    1. Preview project (starting at Title Layout)

    2. Click "Game" button and move mouse around. Note how the sprite smoothly follows the cursor around the layout.

    3. Click the "Title" button to return to the title layout.

    4. Click "Save" to save the game state.

    5. Close the preview.

    6. Preview the project (starting at Title Layout)

    7. Click "Load" button to load the previously saved game.

    8. Click "Game" button to return to Game Layout.

    9. Move mouse around.

    Observed result:

    The sprite does not move around, following the cursor, as it did before. The sprite will move, but only if the cursor is very close to its origin and then it will move in a "jerky" manner as if trying to be in two positions at once.

    Expected result:

    The sprite should move around, following the cursor as before.

    Browsers affected:

    Chrome: yes

    Firefox: yes

    Internet Explorer: no

    Operating system & service pack:

    Windows 7 Ultimate SP1

    Construct 2 version:

        Release 126 (64-bit/Steam)

  • 8 posts