Automatic Systems

Get help using Construct 2

Post » Sat Apr 20, 2013 8:46 am

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.



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

SpaceGame.capxExcal2013-04-20 12:51:19
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Sat Apr 20, 2013 9:22 am

@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.

B
44
S
15
G
9
Posts: 1,096
Reputation: 11,013

Post » Sat Apr 20, 2013 9:33 am

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.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Sat Apr 20, 2013 11:16 am

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

Can someone take a look?
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Sat Apr 20, 2013 2:20 pm

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.TL222013-04-20 14:23:17
B
56
S
20
G
7
Posts: 305
Reputation: 8,754

Post » Sat Apr 20, 2013 2:52 pm

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.



The first .capx link should still be working. Here it is again: SpaceGame.capx
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Sat Apr 20, 2013 2:54 pm

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.TELLES08082013-04-20 14:57:04
ImageImageImageImageImageImage
B
92
S
19
G
12
Posts: 1,192
Reputation: 18,276

Post » Sat Apr 20, 2013 11:20 pm

I did that, but it still seems to work only every now and then.



Capx download link in this thread is updated.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Sun Apr 21, 2013 3:19 am

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."
B
18
S
5
G
1
Posts: 95
Reputation: 2,666

Post » Sun Apr 21, 2013 3:30 am

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.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Next

Return to How do I....?

Who is online

Users browsing this forum: studio UNNAMED and 4 guests