Automatic Systems

0 favourites
  • 13 posts
From the Asset Store
Automatic screen resizing
$1.25 USD
50% off
Save hours of work by resizing items on your game screens.
  • I would like my player ship's shields to automatically activate whenever certain objects are within a certain distance to the player.

    I'm not entirely sure how I would go about accomplishing this properly. The current implementation seems to activate shields sometimes when the harmful objects are in range, and other times not activate at all.

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

    Here's the .capx for those who might want to take a look:

    SpaceGame.capx

  • Excal

    Hi,

    why not place all the objects you want to detect in a family. Then create an invisible sprite set to the radius you want to detect and pin it to the player. Then just check for an overlap between the two.

  • I'm not used to working with families, but part of the reason why they're not in a family is because some objects are hostile to each other. For example, asteroids are hostile to both the player and enemy ships.

    As for the radius, there is no need to create an invisible sprite since I know the radius of the player's shield and simply need to detect if hostile objects are within that radius.

  • Okay, apparently this isn't fixed. I thought it was, but it seems really inconsistent.

    Can someone take a look?

  • Do be a little more patient please. You should wait at least a day before bumping to be honest. At least longer than a couple hours.

    As for your problem, instead of "Pick all (object)" do a "For Each (object)" loop. Also, I'd highly recommend using families. Objects in the same family can still affect each other, and they can be put into multiple families as well. It'll give you less headache for sure.

  • The reason why I bumped was because I posted saying it was fixed. It wasn't. I deleted that post and posted this update.

    I put the objects in a family and set the loop to the family, but now it doesn't seem to be working at all.

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

    The first .capx link should still be working. Here it is again: SpaceGame.capx

  • Like I did on Golden Lotus?

    Put them inside a family and check:

    System>Compare two Variables>distance(family.X,family.Y,Shield.X,Shield.Y) > desired distance = create shield

    Where shield will have the fade behavior and pin to the player.

    You don't need to use "for each", and don't need to use variables, just active the fade when you want and create shield when desired.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I did that, but it still seems to work only every now and then.

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

    Capx download link in this thread is updated.

  • It might be that the code detects a harmful thing inside the radius, turns it on, but then immediately detects one outside of the radius and turns it off.

    Instead of saying "distance(im lazy)" > 82, try copying the distance(still lazy) = 82 and then Inverting it (right click on the condition and invert).

    This will tell it "if there are NO objects inside this radius, turn off" instead of "if an object is outside this radius, turn off."

  • MadameBerry, I think you hit it right on the spot as to why it's not working.

    I'm going to try a Pick Nearest for the family and see if that works.

    By the way, I checked out your blog and read your Kickstarter thread. Sorry to hear it didn't go well, but the lessons learned are invaluable since I plan to launch my own Kickstarter after the Newgrounds C2 game jam.

  • Well, I tried Pick Nearest, did the inverted thing, and neither are working.

    I have no idea why the shields sometimes works and sometimes doesn't.

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

  • Hm... I'm getting multiple different things that work. For instance, this works, as well as inverting the "less than or equal" value.

    <img src="http://imageshack.us/a/img690/6484/workszm.png" border="0" />

    I think what may be happening is that it always calculates from the origin point of the object, so even though the edge of the object is 82 pixels away, the center is still more than that, so it won't turn on.

    You mentioned you'd accounted for the radius of the shield, but I think you need to also add the radius of the object you're detecting for, which may be difficult if the objects in your family are different sizes. You may need to either detect different radiuses separately (which unfortunately means not using a family), or just go with the largest radius and have the shield turn on earlier than normal sometimes.

    <img src="http://imageshack.us/a/img189/4411/works2.png" border="0" />

    <img src="http://imageshack.us/a/img541/1527/works3.png" border="0" />

    Edit: Thanks for checking out my blog!

    And yeah, kickstarter can be a hard market. I think we may try again though. To be honest, our campaign wasn't great the first time around, we didn't present anything nearly well enough. Good luck on your own when it comes!

  • MadameBerry: This solved it, thank you! For some odd reason I didn't think about the size of the object!

    Where are you going to school? I graduate in Fall 2014 too, haha.

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