Terrible Tree Trouble

Get help using Construct 2

Post » Wed Jun 05, 2013 2:49 am

Alright, I am beating my skull over this problem, and I just can't figure it out.

I'm making a tower defense type game, and you can build towers on any tree on the map. I put in my tree sprite, and control-drug the tree to create multiple yet identical trees on the map.

I then made it to where when the player avatar collides with a tree, it turns to 75% opacity (to show that tree is activated) and turns a buildable boolean to "true." I then made it to where when the player avatar is no longer overlapping "tree," opacity is set back to 100% and the boolean becomes "false."

You already see what I didn't, right? If you walk from one tree directly into another tree, BOTH trees activate because I never technically stopped overlapping "tree." In fact, if I don't actually leave the forest, and I walk from tree to tree, I can "activate" 20 different trees if I want, and none of them go back to 100% opacity because I never stopped interacting with "tree." I need to make all of the trees individual instances so when I move from tree to tree the boolean and opacity resets for the tree I just left.

Does this make sense?
B
6
S
1
Posts: 62
Reputation: 532

Post » Wed Jun 05, 2013 3:51 am

You could store the UID of the current tree, Pick all, and then do a foreach on the trees, resetting the values UNLESS the UID is the "current" one - turn those values on.
ImageImageImage
B
71
S
21
G
233
Posts: 3,696
Reputation: 130,368

Post » Wed Jun 05, 2013 4:15 am

I thought I would have to use the UIDs for this as well, but all the commands I tried were wanting a specific UID instead of a range. Would you mind elaborating a bit more on what you mean? I think you might be on to something here, but I am unclear how to do the first couple of steps you outlines. Thank you so much for the help. I really appreciate it.
B
6
S
1
Posts: 62
Reputation: 532

Post » Wed Jun 05, 2013 4:34 am

treesample

See event #9.blackhornet2013-06-05 06:26:05
ImageImageImage
B
71
S
21
G
233
Posts: 3,696
Reputation: 130,368

Post » Wed Jun 05, 2013 10:01 pm

Thank you very much. I have been at work all day so I didn't get to reply before now, but I really appreciate your expedient response. I will work on this problem tonight based upon the information you provided.

I wish I could have replied to this without bumping the thread since it is such a focused issue. Sorry about that. :\
B
6
S
1
Posts: 62
Reputation: 532

Post » Wed Jun 05, 2013 11:44 pm

The link to the capx isn't working. I think the hosting site is having DNS issues or something. I'll try again later. Thanks again. I really appreciate it.
B
6
S
1
Posts: 62
Reputation: 532

Post » Thu Jun 06, 2013 2:24 am

treesample.ZIP

Change .ZIP to .CAPX.
ImageImageImage
B
71
S
21
G
233
Posts: 3,696
Reputation: 130,368

Post » Thu Jun 06, 2013 3:08 am

Thanks for the blackhornet. The code worked brilliantly for solving the majority of the problem, but now the last tree touched won't revert to 100% opacity when I leave the trees. I tried adding an additional condition for "when player is no longer overlapping tree, set opacity to 100%." That didn't solve the problem.

You got me really close though. Brilliant. I certainly appreciate it very much, and the extra effort you put into re-posting the link since the initial link was dead. Kudos sir. Let me know if there is anything I can help you with.
B
6
S
1
Posts: 62
Reputation: 532

Post » Thu Jun 06, 2013 3:20 am

ImageImageImage
B
71
S
21
G
233
Posts: 3,696
Reputation: 130,368

Post » Thu Jun 06, 2013 3:24 am

mmm I usually just Force a 'For each "tree condition on stuff like that and it works fine for me...have you tried that?

Try putting the trees in a Family then add an extra condition "For Each->(TreeFamily)....
that usually works for me....
Its not usually necessary but sometimes FORCING the condition works more consistantly
When in doubt..or you are lost in a Zombie apocalypse or someone is giving you a hard time..Remember one thing..... Read the Construct 2 Manual..it will save your life.:)
B
35
S
13
G
8
Posts: 318
Reputation: 7,685

Next

Return to How do I....?

Who is online

Users browsing this forum: David181, OBLIVION and 28 guests